File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ impl DistString for Standard {
9797 // A char is encoded with at most four bytes, thus this reservation is
9898 // guaranteed to be sufficient. We do not shrink_to_fit afterwards so
9999 // that repeated usage on the same `String` buffer does not reallocate.
100- s. reserve ( s . len ( ) + 4 * len) ;
100+ s. reserve ( 4 * len) ;
101101 s. extend ( Distribution :: < char > :: sample_iter ( self , rng) . take ( len) ) ;
102102 }
103103}
@@ -126,7 +126,7 @@ impl DistString for Alphanumeric {
126126 fn append_string < R : Rng + ?Sized > ( & self , rng : & mut R , string : & mut String , len : usize ) {
127127 unsafe {
128128 let v = string. as_mut_vec ( ) ;
129- v. reserve ( v . len ( ) + len) ;
129+ v. reserve ( len) ;
130130 v. extend ( self . sample_iter ( rng) . take ( len) ) ;
131131 }
132132 }
You can’t perform that action at this time.
0 commit comments