diff options
| author | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2014-10-23 01:42:47 +1100 |
|---|---|---|
| committer | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2014-10-26 09:53:30 +1100 |
| commit | 6a50b4d018b0e44b9e12560030ca7fb240107a68 (patch) | |
| tree | ab6b058b3e3c29a971d440d7266c4f6623851994 /src/libsyntax/ext/tt | |
| parent | ec3f0201e76b5cf689f3e8e6418435c3e6d9271c (diff) | |
| download | rust-6a50b4d018b0e44b9e12560030ca7fb240107a68.tar.gz rust-6a50b4d018b0e44b9e12560030ca7fb240107a68.zip | |
Prevent some vector reallocations
Diffstat (limited to 'src/libsyntax/ext/tt')
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index e705c4d8b33..c0b66851dfe 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -202,14 +202,14 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { (*frame.forest)[frame.idx].clone() }; match t { - TTDelimited(_, open, delimed_tts, close) => { - let mut tts = vec![]; - tts.push(open.to_tt()); - tts.extend(delimed_tts.iter().map(|x| (*x).clone())); - tts.push(close.to_tt()); + TTDelimited(_, open, tts, close) => { + let mut forest = Vec::with_capacity(1 + tts.len() + 1); + forest.push(open.to_tt()); + forest.extend(tts.iter().map(|x| (*x).clone())); + forest.push(close.to_tt()); r.stack.push(TtFrame { - forest: Rc::new(tts), + forest: Rc::new(forest), idx: 0, dotdotdoted: false, sep: None |
