]> git.lizzy.rs Git - rust.git/commit
Optimize strip_prefix and strip_suffix with str patterns
authorNikhil Benesch <nikhil.benesch@gmail.com>
Fri, 6 Mar 2020 20:11:24 +0000 (15:11 -0500)
committerNikhil Benesch <nikhil.benesch@gmail.com>
Mon, 30 Mar 2020 15:10:21 +0000 (11:10 -0400)
commitac478f2f610bd93c25c82491526ea153ad103ac0
treebc7425330cc13fef5f5be8176edfc5f677177284
parente768d6f0bc6db7a46c9ef08254a944ba100bc5dd
Optimize strip_prefix and strip_suffix with str patterns

Constructing a Searcher in strip_prefix and strip_suffix is
unnecessarily slow when the pattern is a fixed-length string. Add
strip_prefix and strip_suffix methods to the Pattern trait, and add
optimized implementations of these methods in the str implementation.
The old implementation is retained as the default for these methods.
src/liballoc/string.rs
src/libcore/str/mod.rs
src/libcore/str/pattern.rs