diff options
| author | bors <bors@rust-lang.org> | 2014-02-08 05:01:30 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-02-08 05:01:30 -0800 |
| commit | 5acc998ed9b76d9c00849e007101f9c33b17c6c4 (patch) | |
| tree | 1f1a5ad2080acda5446285f9da7077938cddd9df /src/libsyntax | |
| parent | 548b8cec199c28c102fd98d6dd2833d3a171e7d0 (diff) | |
| parent | 1d17c2129ec696d81e6c6caee8b1740dd9509090 (diff) | |
| download | rust-5acc998ed9b76d9c00849e007101f9c33b17c6c4.tar.gz rust-5acc998ed9b76d9c00849e007101f9c33b17c6c4.zip | |
auto merge of #12098 : kballard/rust/from_utf8_lossy_tweak, r=huonw
MaybeOwned allows from_utf8_lossy to avoid allocation if there are no invalid bytes in the input. Before: ``` test str::bench::from_utf8_lossy_100_ascii ... bench: 183 ns/iter (+/- 5) test str::bench::from_utf8_lossy_100_invalid ... bench: 341 ns/iter (+/- 15) test str::bench::from_utf8_lossy_100_multibyte ... bench: 227 ns/iter (+/- 13) test str::bench::from_utf8_lossy_invalid ... bench: 102 ns/iter (+/- 4) test str::bench::is_utf8_100_ascii ... bench: 2 ns/iter (+/- 0) test str::bench::is_utf8_100_multibyte ... bench: 2 ns/iter (+/- 0) ``` Now: ``` test str::bench::from_utf8_lossy_100_ascii ... bench: 96 ns/iter (+/- 4) test str::bench::from_utf8_lossy_100_invalid ... bench: 318 ns/iter (+/- 10) test str::bench::from_utf8_lossy_100_multibyte ... bench: 105 ns/iter (+/- 2) test str::bench::from_utf8_lossy_invalid ... bench: 105 ns/iter (+/- 2) test str::bench::is_utf8_100_ascii ... bench: 2 ns/iter (+/- 0) test str::bench::is_utf8_100_multibyte ... bench: 2 ns/iter (+/- 0) ```
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index aeeae94238b..93574f4d858 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4200,10 +4200,10 @@ impl Parser { let mut err = ~"circular modules: "; let len = included_mod_stack.get().len(); for p in included_mod_stack.get().slice(i, len).iter() { - p.display().with_str(|s| err.push_str(s)); + err.push_str(p.display().as_maybe_owned().as_slice()); err.push_str(" -> "); } - path.display().with_str(|s| err.push_str(s)); + err.push_str(path.display().as_maybe_owned().as_slice()); self.span_fatal(id_sp, err); } None => () |
