Skip to content

Commit bdaaf97

Browse files
authored
Fix usage of deprecated APIs. (#219)
These were spotted with -Wdeprecated-declarations in a clang build. No functionality change.
1 parent 93d0a64 commit bdaaf97

9 files changed

+14
-15
lines changed

src/s2/encoded_s2point_vector.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ bool EncodedS2PointVector::Init(Decoder* decoder) {
105105

106106
// Peek at the format but don't advance the decoder; the format-specific
107107
// Init functions will do that.
108-
format_ = static_cast<Format>(*decoder->ptr() & kEncodingFormatMask);
108+
format_ = static_cast<Format>(*decoder->skip(0) & kEncodingFormatMask);
109109
switch (format_) {
110110
case UNCOMPRESSED:
111111
return InitUncompressedFormat(decoder);
@@ -196,7 +196,7 @@ bool EncodedS2PointVector::InitUncompressedFormat(Decoder* decoder) {
196196
size_t bytes = size_t{size_} * sizeof(S2Point);
197197
if (decoder->avail() < bytes) return false;
198198

199-
uncompressed_.points = reinterpret_cast<const S2Point*>(decoder->ptr());
199+
uncompressed_.points = reinterpret_cast<const S2Point*>(decoder->skip(0));
200200
decoder->skip(bytes);
201201
return true;
202202
}

src/s2/encoded_string_vector.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void StringVectorEncoder::Encode(Span<const string> v, Encoder* encoder) {
4646

4747
bool EncodedStringVector::Init(Decoder* decoder) {
4848
if (!offsets_.Init(decoder)) return false;
49-
data_ = reinterpret_cast<const char*>(decoder->ptr());
49+
data_ = reinterpret_cast<const char*>(decoder->skip(0));
5050
if (offsets_.size() > 0) {
5151
uint64 length = offsets_[offsets_.size() - 1];
5252
if (decoder->avail() < length) return false;

src/s2/encoded_uint_vector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ inline T GetUintWithLength(const char* ptr, int length) {
192192
template <class T>
193193
bool DecodeUintWithLength(int length, Decoder* decoder, T* result) {
194194
if (decoder->avail() < length) return false;
195-
const char* ptr = reinterpret_cast<const char*>(decoder->ptr());
195+
const char* ptr = reinterpret_cast<const char*>(decoder->skip(0));
196196
*result = GetUintWithLength<T>(ptr, length);
197197
decoder->skip(length);
198198
return true;
@@ -231,7 +231,7 @@ bool EncodedUintVector<T>::Init(Decoder* decoder) {
231231
if (size_ > std::numeric_limits<size_t>::max() / sizeof(T)) return false;
232232
size_t bytes = size_ * len_;
233233
if (decoder->avail() < bytes) return false;
234-
data_ = reinterpret_cast<const char*>(decoder->ptr());
234+
data_ = reinterpret_cast<const char*>(decoder->skip(0));
235235
decoder->skip(bytes);
236236
return true;
237237
}

src/s2/s2builderutil_get_snapped_winding_delta.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ S2Point GetConnector(const S2Point& b0, const S2Point& b1,
173173
// Otherwise we use the point on (B0, B1) that is 90 degrees away from B1'.
174174
// This is sufficient to ensure conditions (1) and (2).
175175
S2Point x = S2::RobustCrossProd(b0, b1).CrossProd(b1_snapped).Normalize();
176-
return (x.DotProd(S2::Interpolate(0.5, b0, b1)) >= 0) ? x : -x;
176+
return (x.DotProd(S2::Interpolate(b0, b1, 0.5)) >= 0) ? x : -x;
177177
}
178178

179179
// Returns the set of incoming and outgoing edges incident to the given

src/s2/s2cap.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ S2Cap S2Cap::Union(const S2Cap& other) const {
127127
return *this;
128128
} else {
129129
S1Angle result_radius = 0.5 * (distance + this_radius + other_radius);
130-
S2Point result_center = S2::InterpolateAtDistance(
131-
0.5 * (distance - this_radius + other_radius),
130+
S2Point result_center = S2::GetPointOnLine(
132131
center(),
133-
other.center());
132+
other.center(),
133+
0.5 * (distance - this_radius + other_radius));
134134
return S2Cap(result_center, result_radius);
135135
}
136136
}

src/s2/s2convex_hull_query.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ unique_ptr<S2Loop> S2ConvexHullQuery::GetSingleEdgeLoop(const S2Point& a,
203203
vector<S2Point> vertices;
204204
vertices.push_back(a);
205205
vertices.push_back(b);
206-
vertices.push_back(S2::Interpolate(0.5, a, b));
206+
vertices.push_back(S2::Interpolate(a, b, 0.5));
207207
auto loop = make_unique<S2Loop>(vertices);
208208
// The resulting loop may be clockwise, so invert it if necessary.
209209
loop->Normalize();

src/s2/s2edge_tessellator.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ S1ChordAngle S2EdgeTessellator::EstimateMaxError(
201201

202202
constexpr double t1 = kInterpolationFraction;
203203
constexpr double t2 = 1 - kInterpolationFraction;
204-
S2Point mid1 = S2::Interpolate(t1, a, b);
205-
S2Point mid2 = S2::Interpolate(t2, a, b);
204+
S2Point mid1 = S2::Interpolate(a, b, t1);
205+
S2Point mid2 = S2::Interpolate(a, b, t2);
206206
S2Point pmid1 = proj_.Unproject(proj_.Interpolate(t1, pa, pb));
207207
S2Point pmid2 = proj_.Unproject(proj_.Interpolate(t2, pa, pb));
208208
return std::max(S1ChordAngle(mid1, pmid1), S1ChordAngle(mid2, pmid2));

src/s2/s2loop.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ bool S2Loop::DecodeInternal(Decoder* const decoder,
644644
#endif
645645
if (within_scope && !is_misaligned) {
646646
vertices_ = const_cast<S2Point *>(reinterpret_cast<const S2Point*>(
647-
decoder->ptr()));
647+
decoder->skip(0)));
648648
decoder->skip(num_vertices_ * sizeof(*vertices_));
649649
owns_vertices_ = false;
650650
} else {

src/s2/s2polyline.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ S2Point S2Polyline::GetSuffix(double fraction, int* next_vertex) const {
238238
if (target < length) {
239239
// This interpolates with respect to arc length rather than
240240
// straight-line distance, and produces a unit-length result.
241-
S2Point result = S2::InterpolateAtDistance(target, vertex(i-1),
242-
vertex(i));
241+
S2Point result = S2::GetPointOnLine(vertex(i-1), vertex(i), target);
243242
// It is possible that (result == vertex(i)) due to rounding errors.
244243
*next_vertex = (result == vertex(i)) ? (i + 1) : i;
245244
return result;

0 commit comments

Comments
 (0)