]> git.lizzy.rs Git - rust.git/commit
core: Unroll the loop in the slice iterator search methods
authorUlrik Sverdrup <bluss@users.noreply.github.com>
Wed, 23 Nov 2016 22:02:30 +0000 (23:02 +0100)
committerUlrik Sverdrup <bluss@users.noreply.github.com>
Thu, 24 Nov 2016 15:55:46 +0000 (16:55 +0100)
commita54ddfb676c59bcf0dd3dc8ef869a6e5ac4afc0b
tree46a2f3a421d54269a87342b9c9f0c928f2e66f62
parent7611e424a7274ab1094ceebc0381e36e81b4db72
core: Unroll the loop in the slice iterator search methods

Introduce a helper method .search_while() that generalizes internal
iteration (Iterator's all, find, position, fold and so on).

The compiler does not unroll loops with conditional exits; we can do
this manually instead to improve the performance of for example
Iterator::find and Iterator::position when used on the slice iterators.

The unrolling is patterned on libstdc++'s implementation of std::find_if.
src/libcore/slice.rs