@@ -493,11 +493,11 @@ impl Regex {
493493 if limit > 0 && i >= limit {
494494 break
495495 }
496- extend_from_slice ( & mut new , & text[ last_match..m. start ( ) ] ) ;
497- extend_from_slice ( & mut new , & * rep) ;
496+ new . extend_from_slice ( & text[ last_match..m. start ( ) ] ) ;
497+ new . extend_from_slice ( & rep) ;
498498 last_match = m. end ( ) ;
499499 }
500- extend_from_slice ( & mut new , & text[ last_match..] ) ;
500+ new . extend_from_slice ( & text[ last_match..] ) ;
501501 return Cow :: Owned ( new) ;
502502 }
503503
@@ -515,11 +515,11 @@ impl Regex {
515515 }
516516 // unwrap on 0 is OK because captures only reports matches
517517 let m = cap. get ( 0 ) . unwrap ( ) ;
518- extend_from_slice ( & mut new , & text[ last_match..m. start ( ) ] ) ;
518+ new . extend_from_slice ( & text[ last_match..m. start ( ) ] ) ;
519519 rep. replace_append ( & cap, & mut new) ;
520520 last_match = m. end ( ) ;
521521 }
522- extend_from_slice ( & mut new , & text[ last_match..] ) ;
522+ new . extend_from_slice ( & text[ last_match..] ) ;
523523 Cow :: Owned ( new)
524524 }
525525}
@@ -980,7 +980,7 @@ impl<'a> Replacer for &'a [u8] {
980980
981981impl < F > Replacer for F where F : FnMut ( & Captures ) -> Vec < u8 > {
982982 fn replace_append ( & mut self , caps : & Captures , dst : & mut Vec < u8 > ) {
983- extend_from_slice ( dst , & ( * self ) ( caps) ) ;
983+ dst . extend_from_slice ( & ( * self ) ( caps) ) ;
984984 }
985985}
986986
@@ -996,26 +996,10 @@ pub struct NoExpand<'r>(pub &'r [u8]);
996996
997997impl < ' a > Replacer for NoExpand < ' a > {
998998 fn replace_append ( & mut self , _: & Captures , dst : & mut Vec < u8 > ) {
999- extend_from_slice ( dst , self . 0 ) ;
999+ dst . extend_from_slice ( self . 0 ) ;
10001000 }
10011001
10021002 fn no_expansion < ' r > ( & ' r mut self ) -> Option < Cow < ' r , [ u8 ] > > {
10031003 Some ( Cow :: Borrowed ( self . 0 ) )
10041004 }
10051005}
1006-
1007- /// This hopefully has the same performance characteristics as
1008- /// Vec::extend_from_slice (which was introduced in Rust 1.6), but works on
1009- /// Rust 1.3.
1010- ///
1011- /// N.B. Remove this once we do a semver bump. At that point, we'll bump
1012- /// required Rust version to at least 1.6.
1013- fn extend_from_slice ( dst : & mut Vec < u8 > , src : & [ u8 ] ) {
1014- dst. reserve ( src. len ( ) ) ;
1015- let dst_len = dst. len ( ) ;
1016- unsafe { dst. set_len ( dst_len + src. len ( ) ) ; }
1017- let mut dst = & mut dst[ dst_len..dst_len + src. len ( ) ] ;
1018- for i in 0 ..src. len ( ) {
1019- dst[ i] = src[ i] ;
1020- }
1021- }
0 commit comments