mirror of
https://gitee.com/openharmony/third_party_rust_syn
synced 2024-11-23 07:50:04 +00:00
Merge pull request #1204 from dtolnay/prealloc
Preallocate TokenBuffer vector
This commit is contained in:
commit
548332634d
@ -59,9 +59,10 @@ impl TokenBuffer {
|
||||
fn inner_new(stream: TokenStream, up: *const Entry) -> TokenBuffer {
|
||||
// Build up the entries list, recording the locations of any Groups
|
||||
// in the list to be processed later.
|
||||
let mut entries = Vec::new();
|
||||
let iterator = stream.into_iter();
|
||||
let mut entries = Vec::with_capacity(iterator.size_hint().0 + 1);
|
||||
let mut groups = Vec::new();
|
||||
for tt in stream {
|
||||
for tt in iterator {
|
||||
match tt {
|
||||
TokenTree::Ident(ident) => {
|
||||
entries.push(Entry::Ident(ident));
|
||||
|
Loading…
Reference in New Issue
Block a user