diff options
| author | Kouhei Yanagita <yanagi@shakenbu.org> | 2023-09-16 12:10:09 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-16 12:10:09 +0900 |
| commit | 7d08dbd015a16c27f2d9c77751e80fa6efba2d7a (patch) | |
| tree | f40369e5c50acc88026c5221695443342fb5c49c /test/ruby/test_range.rb | |
| parent | 67dedf8cf634843488a477e53b9995b63e9aa291 (diff) | |
Optimize Range#bsearch for beginless/endless ranges
On Range#bsearch for endless ranges, we try positions at `begin + 2**i` (i = 0, 1, 2, ...)
to find a point that satisfies a given condition.
Subsequently, we perform binary searching with the interval `[begin, begin + 2**n]`.
However, the interval `[begin + 2**(n-1), begin + 2**n]` is sufficient for binary search
because `begin + 2**(n-1)` does not satisfy the condition.
The same applies to beginless ranges.
Diffstat (limited to 'test/ruby/test_range.rb')
0 files changed, 0 insertions, 0 deletions
