@@ -512,24 +512,6 @@ impl String {
512
512
#[ inline]
513
513
#[ stable = "function just renamed from push_char" ]
514
514
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 ) {
533
515
if ( ch as u32 ) < 0x80 {
534
516
self . vec . push ( ch as u8 ) ;
535
517
return ;
@@ -1455,17 +1437,6 @@ mod tests {
1455
1437
} ) ;
1456
1438
}
1457
1439
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
-
1469
1440
#[ bench]
1470
1441
fn bench_push_char_two_bytes ( b : & mut Bencher ) {
1471
1442
b. bytes = REPETITIONS * 2 ;
@@ -1477,17 +1448,6 @@ mod tests {
1477
1448
} ) ;
1478
1449
}
1479
1450
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
-
1491
1451
#[ bench]
1492
1452
fn from_utf8_lossy_100_ascii ( b : & mut Bencher ) {
1493
1453
let s = b"Hello there, the quick brown fox jumped over the lazy dog! \
0 commit comments