mozilla/rust — pull request #12241 by huonw (2014-02-13 12:55:00+00:00)
Title: std::str: optimize is_utf8 & first_non_utf8_index.

This makes is_utf8 up to 40% faster

Before:

is_utf8_100_ascii ... bench: 123 ns/iter (+/- 9)
is_utf8_100_multibyte ... bench: 134 ns/iter (+/- 7)

from_utf8_lossy_100_ascii ... bench: 118 ns/iter (+/- 8)
from_utf8_lossy_100_invalid ... bench: 378 ns/iter (+/- 12)
from_utf8_lossy_100_multibyte ... bench: 135 ns/iter (+/- 5)
from_utf8_lossy_invalid ... bench: 129 ns/iter (+/- 10)

After:

is_utf8_100_ascii ... bench: 77 ns/iter (+/- 4)
is_utf8_100_multibyte ... bench: 96 ns/iter (+/- 9)

from_utf8_lossy_100_ascii ... bench: 91 ns/iter (+/- 14)
from_utf8_lossy_100_invalid ... bench: 414 ns/iter (+/- 30)
from_utf8_lossy_100_multibyte ... bench: 119 ns/iter (+/- 10)
from_utf8_lossy_invalid ... bench: 108 ns/iter (+/- 11)