diff options
| author | bors <bors@rust-lang.org> | 2015-08-25 12:31:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-08-25 12:31:11 +0000 |
| commit | 74728862339e156ecc10dd5a515f51bbaf9b4192 (patch) | |
| tree | 8640ca3cd2e598fee81a15ef93ebf5fd07971b7e | |
| parent | 5c630a61c658cb7d861a60da6951ee06619337b2 (diff) | |
| parent | 81c1d142d31736a8b65c111c3aa4a1a5723ee4e5 (diff) | |
Auto merge of #27986 - chris-morgan:reduce-string-extend-str-implementation, r=bluss
Reserving lower_bound bytes was just silly. It’d be perfectly reasonable to have empty strings in the iterator, which could cause superfluous reallocation of the string, or to have more than one byte per string, which could cause additional reallocation (in practice it’ll balance out). The added complexity of this logic is simply pointless, adding a little bloat with no demonstrable advantage and slight disadvantage.
| -rw-r--r-- | src/libcollections/string.rs | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 5c5f6cace6a..a8f030c437d 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -813,11 +813,7 @@ impl<'a> Extend<&'a char> for String { #[stable(feature = "rust1", since = "1.0.0")] impl<'a> Extend<&'a str> for String { fn extend<I: IntoIterator<Item=&'a str>>(&mut self, iterable: I) { - let iterator = iterable.into_iter(); - // A guess that at least one byte per iterator element will be needed. - let (lower_bound, _) = iterator.size_hint(); - self.reserve(lower_bound); - for s in iterator { + for s in iterable { self.push_str(s) } } |
