servo/rust-cssparser — pull request #66 by ayosec (2014-12-18 22:19:19+00:00)
Title: Function tokenizer::preprocess 3x faster

I added a bench to test the difference:

```rust
fn bench_preprocess(b: &mut test::Bencher) {
let source = "Lorem\n\t\u{FFFD}ipusm\ndoror\u{FFFD}á\n";
b.iter(|| {
let _ = super::preprocess(source);
});
}
```

With the old function, with 3 `replace()` (commit ea6c1b721):

test tokenizer::bench_preprocess::bench_preprocess ... bench: 440 ns/iter (+/- 24)

With the new function:

test tokenizer::bench_preprocess::bench_preprocess ... bench: 142 ns/iter (+/- 6)

I'm a newbie in Rust, so I guess that there are a lot of improvements to be done.