rust/src/libcore
Ulrik Sverdrup 2b82c072c7 StrSearcher: Improve inner loop in TwoWaySearcher::next, next_back
The innermost loop of TwoWaySearcher checks the boundary of the haystack
vs position + needle.len(), and it checks the last byte of the needle
against the byteset.

If these two steps are combined by using the indexing of the last
needle byte's position as bounds check, the algorithm improves its
throughput. We improve the innermost loop by reducing the number of
instructions used, and elminating the panic case for the checked
indexing that was previously used.

Selected benchmarks from the external/workspace testsuite. Benchmarks
improve across the board.

```
before:

test bb_in_aa::twoway_find                  ... bench:       4,229 ns/iter (+/- 1,305) = 23646 MB/s
test bb_in_aa::twoway_rfind                 ... bench:       3,873 ns/iter (+/- 101) = 25819 MB/s
test short_1let_long::twoway_find           ... bench:       7,075 ns/iter (+/- 29) = 360 MB/s
test short_1let_long::twoway_rfind          ... bench:       6,640 ns/iter (+/- 79) = 384 MB/s
test short_2let_long::twoway_find           ... bench:       3,823 ns/iter (+/- 16) = 667 MB/s
test short_2let_long::twoway_rfind          ... bench:       3,774 ns/iter (+/- 44) = 675 MB/s
test short_3let_long::twoway_find           ... bench:       3,582 ns/iter (+/- 47) = 712 MB/s
test short_3let_long::twoway_rfind          ... bench:       3,616 ns/iter (+/- 34) = 705 MB/s

with this commit:

test bb_in_aa::twoway_find                  ... bench:       2,952 ns/iter (+/- 20) = 33875 MB/s
test bb_in_aa::twoway_rfind                 ... bench:       2,939 ns/iter (+/- 99) = 34025 MB/s
test short_1let_long::twoway_find           ... bench:       4,593 ns/iter (+/- 4) = 555 MB/s
test short_1let_long::twoway_rfind          ... bench:       4,592 ns/iter (+/- 76) = 555 MB/s
test short_2let_long::twoway_find           ... bench:       2,804 ns/iter (+/- 3) = 909 MB/s
test short_2let_long::twoway_rfind          ... bench:       2,807 ns/iter (+/- 40) = 908 MB/s
test short_3let_long::twoway_find           ... bench:       3,105 ns/iter (+/- 120) = 821 MB/s
test short_3let_long::twoway_rfind          ... bench:       3,019 ns/iter (+/- 50) = 844 MB/s
```

- `bb_in_aa`: fast skip due to byteset filter loop improves.
- 1/2/3let: Searches for 1, 2, or 3 ascii bytes improves.
2015-08-07 13:41:17 +02:00
..
fmt Rollup merge of #27326 - steveklabnik:doc_show_use, r=Gankro 2015-07-29 10:30:34 -04:00
hash Auto merge of #27370 - alexcrichton:stabilize-easy, r=brson 2015-07-31 02:57:34 +00:00
num Replace occurences of illegal in user facing docs 2015-07-28 17:55:44 +03:00
str StrSearcher: Improve inner loop in TwoWaySearcher::next, next_back 2015-08-07 13:41:17 +02:00
any.rs Auto merge of #26725 - tshepang:patch-2, r=bluss 2015-07-02 21:56:28 +00:00
array.rs std: Create separate docs for the primitives 2015-07-20 13:18:06 -07:00
atomic.rs Auto merge of #27052 - wthrowe:atomic_send, r=Gankro 2015-07-30 04:18:50 +00:00
cell.rs Show appropriate feature flags in docs 2015-07-27 12:28:13 -04:00
char.rs Add unstable attribute to char::from_u32_unchecked 2015-07-24 01:58:38 +02:00
clone.rs core: Split apart the global core feature 2015-06-17 09:06:59 -07:00
cmp.rs Rollup merge of #27326 - steveklabnik:doc_show_use, r=Gankro 2015-07-29 10:30:34 -04:00
cmp_macros.rs std: Remove #[old_orphan_check] from PartialEq 2015-03-31 13:39:14 -07:00
convert.rs core: Split apart the global core feature 2015-06-17 09:06:59 -07:00
default.rs Remove doc-comment default::Default imports 2015-04-22 09:42:36 -04:00
intrinsics.rs Register new snapshots (2015-07-26 a5c12f4). 2015-07-27 13:31:48 +03:00
iter.rs Rollup merge of #27326 - steveklabnik:doc_show_use, r=Gankro 2015-07-29 10:30:34 -04:00
lib.rs Auto merge of #27382 - brson:gate-assoc-type, r=alexcrichton 2015-07-31 04:33:34 +00:00
macros.rs std: Remove the curious inner module 2015-07-29 14:18:24 -07:00
marker.rs Replace occurences of illegal in user facing docs 2015-07-28 17:55:44 +03:00
mem.rs Auto merge of #26473 - Eljay:missing_docs, r=alexcrichton 2015-07-05 20:37:26 +00:00
nonzero.rs core: Split apart the global core feature 2015-06-17 09:06:59 -07:00
ops.rs Rollup merge of #27238 - steveklabnik:gh26927, r=huonw 2015-07-24 14:56:03 -04:00
option.rs Show appropriate feature flags in docs 2015-07-27 12:28:13 -04:00
panicking.rs core: Split apart the global core feature 2015-06-17 09:06:59 -07:00
prelude.rs core: Split apart the global core feature 2015-06-17 09:06:59 -07:00
ptr.rs std: Remove the curious inner module 2015-07-29 14:18:24 -07:00
raw.rs Show appropriate feature flags in docs 2015-07-27 12:28:13 -04:00
result.rs Rollup merge of #27326 - steveklabnik:doc_show_use, r=Gankro 2015-07-29 10:30:34 -04:00
simd.rs Show appropriate feature flags in docs 2015-07-27 12:28:13 -04:00
slice.rs Auto merge of #27358 - bluss:split-at-mut, r=aturon 2015-07-29 09:57:50 +00:00
tuple.rs std: Create separate docs for the primitives 2015-07-20 13:18:06 -07:00