Skip to content

Commit e40a81b

Browse files
committed
Merge String::push_with_ascii_fast_path into String::push.
1 parent cc33ce6 commit e40a81b

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

src/libcollections/string.rs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -512,24 +512,6 @@ impl String {
512512
#[inline]
513513
#[stable = "function just renamed from push_char"]
514514
pub fn push(&mut self, ch: char) {
515-
let cur_len = self.len();
516-
// This may use up to 4 bytes.
517-
self.vec.reserve(4);
518-
519-
unsafe {
520-
// Attempt to not use an intermediate buffer by just pushing bytes
521-
// directly onto this string.
522-
let slice = RawSlice {
523-
data: self.vec.as_ptr().offset(cur_len as int),
524-
len: 4,
525-
};
526-
let used = ch.encode_utf8(mem::transmute(slice)).unwrap_or(0);
527-
self.vec.set_len(cur_len + used);
528-
}
529-
}
530-
531-
#[inline]
532-
fn push_with_ascii_fast_path(&mut self, ch: char) {
533515
if (ch as u32) < 0x80 {
534516
self.vec.push(ch as u8);
535517
return;
@@ -1455,17 +1437,6 @@ mod tests {
14551437
});
14561438
}
14571439

1458-
#[bench]
1459-
fn bench_push_char_one_byte_with_fast_path(b: &mut Bencher) {
1460-
b.bytes = REPETITIONS;
1461-
b.iter(|| {
1462-
let mut r = String::new();
1463-
for _ in range(0, REPETITIONS) {
1464-
r.push_with_ascii_fast_path('a')
1465-
}
1466-
});
1467-
}
1468-
14691440
#[bench]
14701441
fn bench_push_char_two_bytes(b: &mut Bencher) {
14711442
b.bytes = REPETITIONS * 2;
@@ -1477,17 +1448,6 @@ mod tests {
14771448
});
14781449
}
14791450

1480-
#[bench]
1481-
fn bench_push_char_two_bytes_with_slow_path(b: &mut Bencher) {
1482-
b.bytes = REPETITIONS * 2;
1483-
b.iter(|| {
1484-
let mut r = String::new();
1485-
for _ in range(0, REPETITIONS) {
1486-
r.push_with_ascii_fast_path('â')
1487-
}
1488-
});
1489-
}
1490-
14911451
#[bench]
14921452
fn from_utf8_lossy_100_ascii(b: &mut Bencher) {
14931453
let s = b"Hello there, the quick brown fox jumped over the lazy dog! \

0 commit comments

Comments
 (0)