Commit f031275
committed
fix: improve perf of count with smarter handling of half-open range
The BITS paper uses fully inclusive ranges. When this was written
I'm not sure I understood that. To get things to match the naive
version of count (find -> count) I had a while loop in the bits
count method to advance the cursor past the matched start/stop
index.
This change was found while porting mojo-lapper and removes the
while loop. It also has a more effecient branchless binary search.
Benchmarks for count improve 24-30% (see PR).1 parent 828fec7 commit f031275
3 files changed
Lines changed: 16 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
353 | | - | |
| 353 | + | |
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
| |||
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
425 | | - | |
| 425 | + | |
426 | 426 | | |
| 427 | + | |
| 428 | + | |
427 | 429 | | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | 430 | | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
441 | 437 | | |
442 | | - | |
| 438 | + | |
443 | 439 | | |
444 | 440 | | |
445 | 441 | | |
| |||
587 | 583 | | |
588 | 584 | | |
589 | 585 | | |
590 | | - | |
| 586 | + | |
| 587 | + | |
591 | 588 | | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | 589 | | |
602 | 590 | | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | 591 | | |
608 | 592 | | |
609 | 593 | | |
| |||
1022 | 1006 | | |
1023 | 1007 | | |
1024 | 1008 | | |
| 1009 | + | |
1025 | 1010 | | |
1026 | 1011 | | |
1027 | 1012 | | |
| |||
0 commit comments