File tree 1 file changed +5
-11
lines changed
1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -490,7 +490,7 @@ where
490
490
pub fn pop ( & mut self ) -> Option < char > {
491
491
debug ! ( "Pop" ) ;
492
492
self . as_str ( ) . chars ( ) . last ( ) . map ( |ch| {
493
- self . size = self . size . saturating_sub ( ch. len_utf8 ( ) . into_lossy ( ) ) ;
493
+ self . size -= ch. len_utf8 ( ) . into_lossy ( ) ;
494
494
ch
495
495
} )
496
496
}
@@ -534,9 +534,8 @@ where
534
534
end = pos;
535
535
}
536
536
537
+ let _ = self . replace_range ( end.., "" ) ;
537
538
let _ = self . replace_range ( ..start, "" ) ;
538
- // Note: Garanteed to not overflow but that should not be the bottleneck
539
- let _ = self . replace_range ( end. saturating_sub ( start) .., "" ) ;
540
539
}
541
540
542
541
/// Removes specified char from `ArrayString`
@@ -877,19 +876,14 @@ where
877
876
let ptr = self . array . as_mut_ptr ( ) ;
878
877
core:: ptr:: copy (
879
878
ptr. add ( end) ,
880
- ptr. add ( str. len ( ) . saturating_add ( start) ) ,
881
- this_len. saturating_sub ( end) ,
879
+ ptr. add ( str. len ( ) ) . add ( start) ,
880
+ this_len - end,
882
881
) ;
883
882
if !str. is_empty ( ) {
884
883
core:: ptr:: copy ( str. as_ptr ( ) , ptr. add ( start) , str. len ( ) ) ;
885
884
}
886
885
}
887
- self . size = self
888
- . len ( )
889
- . saturating_add ( str. len ( ) )
890
- . saturating_add ( start)
891
- . saturating_sub ( end)
892
- . into_lossy ( ) ;
886
+ self . size += str. len ( ) + start + end;
893
887
Ok ( ( ) )
894
888
}
895
889
}
You can’t perform that action at this time.
0 commit comments