We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fa17d1c commit 81f1af8Copy full SHA for 81f1af8
src/distributions/other.rs
@@ -97,7 +97,7 @@ impl DistString for Standard {
97
// A char is encoded with at most four bytes, thus this reservation is
98
// guaranteed to be sufficient. We do not shrink_to_fit afterwards so
99
// that repeated usage on the same `String` buffer does not reallocate.
100
- s.reserve(s.len() + 4 * len);
+ s.reserve(4 * len);
101
s.extend(Distribution::<char>::sample_iter(self, rng).take(len));
102
}
103
@@ -126,7 +126,6 @@ impl DistString for Alphanumeric {
126
fn append_string<R: Rng + ?Sized>(&self, rng: &mut R, string: &mut String, len: usize) {
127
unsafe {
128
let v = string.as_mut_vec();
129
- v.reserve(v.len() + len);
130
v.extend(self.sample_iter(rng).take(len));
131
132
0 commit comments