diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2014-12-20 17:29:02 +0000 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2014-12-20 17:36:30 +0000 |
| commit | e40a81b37bf11ae6f7fc3294ac17230eabaaab03 (patch) | |
| tree | 19576c633698fff4ac5f2f2a17531c919bddd6c9 /src/libcollections/string.rs | |
| parent | cc33ce6fd07467bca1006823ae7336e84054726c (diff) | |
| download | rust-e40a81b37bf11ae6f7fc3294ac17230eabaaab03.tar.gz rust-e40a81b37bf11ae6f7fc3294ac17230eabaaab03.zip | |
Merge String::push_with_ascii_fast_path into String::push.
Diffstat (limited to 'src/libcollections/string.rs')
| -rw-r--r-- | src/libcollections/string.rs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index d894f0b58d9..678e81d40b4 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -512,24 +512,6 @@ impl String { #[inline] #[stable = "function just renamed from push_char"] pub fn push(&mut self, ch: char) { - let cur_len = self.len(); - // This may use up to 4 bytes. - self.vec.reserve(4); - - unsafe { - // Attempt to not use an intermediate buffer by just pushing bytes - // directly onto this string. - let slice = RawSlice { - data: self.vec.as_ptr().offset(cur_len as int), - len: 4, - }; - let used = ch.encode_utf8(mem::transmute(slice)).unwrap_or(0); - self.vec.set_len(cur_len + used); - } - } - - #[inline] - fn push_with_ascii_fast_path(&mut self, ch: char) { if (ch as u32) < 0x80 { self.vec.push(ch as u8); return; @@ -1456,17 +1438,6 @@ mod tests { } #[bench] - fn bench_push_char_one_byte_with_fast_path(b: &mut Bencher) { - b.bytes = REPETITIONS; - b.iter(|| { - let mut r = String::new(); - for _ in range(0, REPETITIONS) { - r.push_with_ascii_fast_path('a') - } - }); - } - - #[bench] fn bench_push_char_two_bytes(b: &mut Bencher) { b.bytes = REPETITIONS * 2; b.iter(|| { @@ -1478,17 +1449,6 @@ mod tests { } #[bench] - fn bench_push_char_two_bytes_with_slow_path(b: &mut Bencher) { - b.bytes = REPETITIONS * 2; - b.iter(|| { - let mut r = String::new(); - for _ in range(0, REPETITIONS) { - r.push_with_ascii_fast_path('รข') - } - }); - } - - #[bench] fn from_utf8_lossy_100_ascii(b: &mut Bencher) { let s = b"Hello there, the quick brown fox jumped over the lazy dog! \ Lorem ipsum dolor sit amet, consectetur. "; |
