]> git.lizzy.rs Git - rust.git/commit
str: Improve .chars().count()
authorUlrik Sverdrup <bluss@users.noreply.github.com>
Sat, 19 Nov 2016 22:18:43 +0000 (23:18 +0100)
committerUlrik Sverdrup <bluss@users.noreply.github.com>
Sat, 19 Nov 2016 22:46:39 +0000 (23:46 +0100)
commit5a3aa2f73cbb08c6e41418c5378791fa24a66146
tree03301105253b3f64744f0c32d7e5f8a5dc4c206c
parentb1da18fe9be180ecfcfb1691c4eb669c496996f5
str: Improve .chars().count()

Use a simpler loop to count the `char` of a string: count the
number of non-continuation bytes. Use `count += <conditional>` which the
compiler understands well and can apply loop optimizations to.
src/libcollectionstest/str.rs
src/libcore/str/mod.rs