| 261 | } |
| 262 | |
| 263 | static inline int32_t Bisect(uint64_t index, const uint64_t* offsets, uint32_t lo, |
| 264 | uint32_t hi) { |
| 265 | // Similar to std::upper_bound(), but slightly different as our offsets |
| 266 | // array always starts with 0. |
| 267 | auto n = hi - lo; |
| 268 | // First iteration does not need to check for n > 1 |
| 269 | // (lo < hi is guaranteed by the precondition). |
| 270 | assert(n > 1 && "lo < hi is a precondition of Bisect"); |
| 271 | do { |
| 272 | const uint32_t m = n >> 1; |
| 273 | const uint32_t mid = lo + m; |
| 274 | if (index >= offsets[mid]) { |
| 275 | lo = mid; |
| 276 | n -= m; |
| 277 | } else { |
| 278 | n = m; |
| 279 | } |
| 280 | } while (n > 1); |
| 281 | return lo; |
| 282 | } |
| 283 | }; |
| 284 | |
| 285 | // Explicitly instantiate template base struct, for DLL linking on Windows |
no outgoing calls
no test coverage detected