@@ -343,11 +343,6 @@ inline void updateBounds(Box<ArrayType>& ioSrc, const Box<ArrayType>& iBox) noex
343343 ioSrc.mMaxY = std::max (ioSrc.mMaxY , iBox.mMaxY );
344344}
345345
346- template <typename ArrayType>
347- inline double axisDistance (ArrayType iValue, ArrayType iMin, ArrayType iMax) noexcept {
348- return std::max (0.0 , std::max<double >(iMin - iValue, iValue - iMax));
349- }
350-
351346template <typename ArrayType>
352347inline double computeDistanceSquared (const Point<ArrayType>& iPoint,
353348 const Box<ArrayType>& iBox) noexcept {
@@ -1168,7 +1163,7 @@ class FlatbushBuilder {
11681163 mItems .reserve (iNumItems);
11691164 }
11701165
1171- inline void clear () noexcept { mItems .clear (); };
1166+ inline void clear () noexcept { mItems .clear (); }
11721167
11731168 inline size_t add (const Box<ArrayType>& iBox) noexcept {
11741169 mItems .push_back (iBox);
@@ -1293,13 +1288,13 @@ class Flatbush {
12931288 double iMaxDistance = gMaxDistance ,
12941289 const FilterCb& iFilterFn = nullptr ) const noexcept ;
12951290
1296- inline size_t nodeSize () const noexcept { return *detail::bit_cast<const uint16_t *>(&mData [2 ]); };
1291+ inline size_t nodeSize () const noexcept { return *detail::bit_cast<const uint16_t *>(&mData [2 ]); }
12971292
1298- inline size_t numItems () const noexcept { return *detail::bit_cast<const uint32_t *>(&mData [4 ]); };
1293+ inline size_t numItems () const noexcept { return *detail::bit_cast<const uint32_t *>(&mData [4 ]); }
12991294
1300- inline size_t indexSize () const noexcept { return mBoxes .size (); };
1295+ inline size_t indexSize () const noexcept { return mBoxes .size (); }
13011296
1302- inline span<const uint8_t > data () const noexcept { return {mData .data (), mData .capacity ()}; };
1297+ inline span<const uint8_t > data () const noexcept { return {mData .data (), mData .capacity ()}; }
13031298
13041299 friend class FlatbushBuilder <ArrayType>;
13051300
@@ -1308,7 +1303,8 @@ class Flatbush {
13081303 static constexpr ArrayType cMinValue = std::numeric_limits<ArrayType>::lowest();
13091304
13101305 static inline double axisDistance (ArrayType iValue, ArrayType iMin, ArrayType iMax) noexcept {
1311- return iValue < iMin ? iMin - iValue : std::max<double >(iValue - iMax, 0.0 );
1306+ return std::max (
1307+ 0.0 , std::max (static_cast <double >(iMin - iValue), static_cast <double >(iValue - iMax)));
13121308 }
13131309
13141310 inline bool canDoSearch (const Box<ArrayType>& iBounds) const {
@@ -1613,16 +1609,18 @@ void Flatbush<ArrayType>::sort(std::vector<uint32_t>& iValues,
16131609#else
16141610 const auto wVals = _mm_xor_si128 (
16151611 _mm_loadu_si128 (detail::bit_cast<const __m128i*>(&iValues[wPos])), detail::kOffset32 );
1616- const auto wMask =
1617- ~_mm_movemask_ps (_mm_castsi128_ps(_mm_cmpgt_epi32(wPivotVecS128, wVals))) & 0xFU ;
1612+ const auto wMask = ~static_cast <unsigned >(_mm_movemask_ps (
1613+ _mm_castsi128_ps (_mm_cmpgt_epi32 (wPivotVecS128, wVals)))) &
1614+ 0xFU ;
16181615#endif
16191616 if (wMask) {
16201617#ifdef _MSC_VER
16211618 unsigned long wBitIdx;
16221619 _BitScanForward (&wBitIdx, static_cast <unsigned >(wMask));
16231620 wPivotLeft = wPos + wBitIdx - 1 ;
16241621#else
1625- wPivotLeft = wPos + __builtin_ctz (static_cast <unsigned >(wMask)) - 1 ;
1622+ wPivotLeft =
1623+ wPos + static_cast <size_t >(__builtin_ctz (static_cast <unsigned >(wMask))) - 1 ;
16261624#endif
16271625 break ;
16281626 }
@@ -1647,16 +1645,19 @@ void Flatbush<ArrayType>::sort(std::vector<uint32_t>& iValues,
16471645#else
16481646 const auto wVals = _mm_xor_si128 (
16491647 _mm_loadu_si128 (detail::bit_cast<const __m128i*>(&iValues[wPos])), detail::kOffset32 );
1650- const auto wMask =
1651- ~_mm_movemask_ps (_mm_castsi128_ps(_mm_cmpgt_epi32(wVals, wPivotVecS128))) & 0xFU ;
1648+ const auto wMask = ~static_cast <unsigned >(_mm_movemask_ps (
1649+ _mm_castsi128_ps (_mm_cmpgt_epi32 (wVals, wPivotVecS128)))) &
1650+ 0xFU ;
16521651#endif
16531652 if (wMask) {
16541653#ifdef _MSC_VER
16551654 unsigned long wBitIdx;
16561655 _BitScanReverse (&wBitIdx, static_cast <unsigned >(wMask));
16571656 wPivotRight = wPos + wBitIdx + 1 ;
16581657#else
1659- wPivotRight = wPos + (31 - __builtin_clz (static_cast <unsigned >(wMask))) + 1 ;
1658+ wPivotRight =
1659+ wPos + (31U - static_cast <unsigned >(__builtin_clz (static_cast <unsigned >(wMask)))) +
1660+ 1 ;
16601661#endif
16611662 break ;
16621663 }
0 commit comments