diff options
| author | Michał Krasnoborski <mkrdln@gmail.com> | 2017-01-27 04:51:24 +0100 |
|---|---|---|
| committer | Michał Krasnoborski <mkrdln@gmail.com> | 2017-01-28 01:50:05 +0100 |
| commit | e74b55b9da5a163e02bbcbf97e7ea24d48742943 (patch) | |
| tree | 3119620b3d5a58f8c433f697452ddf86798c7609 /src/libcollections | |
| parent | 8430042a49bbd49bbb4fbc54f457feb5fb614f56 (diff) | |
use `String::with_capacity` in `format!`
Diffstat (limited to 'src/libcollections')
| -rw-r--r-- | src/libcollections/fmt.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs index 883417e9f4e..bd74848a01d 100644 --- a/src/libcollections/fmt.rs +++ b/src/libcollections/fmt.rs @@ -539,7 +539,8 @@ use string; /// [format!]: ../macro.format.html #[stable(feature = "rust1", since = "1.0.0")] pub fn format(args: Arguments) -> string::String { - let mut output = string::String::new(); + let capacity = args.estimated_capacity(); + let mut output = string::String::with_capacity(capacity); let _ = output.write_fmt(args); output } |
