Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented a smarter TokenStream concatenation system #35539

Merged
merged 1 commit into from
Aug 15, 2016

Conversation

cgswords
Copy link
Contributor

@cgswords cgswords commented Aug 8, 2016

The new algorithm performs 'aggressive compacting' during concatenation as follows:

  • If the nodes' combined total total length is less than 32, we copy both of
    them into a new vector and build a new leaf node.
  • If one node is an internal node and the other is a 'small' leaf (length<32),
    we recur down the internal node on the appropriate side.
    • Otherwise, we construct a new internal node that points to them as left and
      right.

This should produce notably better behavior than the current concatenation implementation.

@rust-highfive
Copy link
Collaborator

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@cgswords
Copy link
Contributor Author

cgswords commented Aug 8, 2016

r? @nrc

@rust-highfive rust-highfive assigned nrc and unassigned sfackler Aug 8, 2016
fn mk_spanned_empty(sp: Span) -> TokenStream {
TokenStream { ts: InternalTS::Empty(sp) }
}

// Construct an leaf node with a 0 offset and length equivalent to the input.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: here and below s/an/a

@nrc
Copy link
Member

nrc commented Aug 9, 2016

Some pretty minor comments inline, otherwise looks good.

@@ -340,6 +340,8 @@ pub struct TokenStream {
ts: InternalTS,
}

static LEAF_SIZE : usize = 32;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be const, not static, also no space before the colon

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and could you add a comment please?

@nrc
Copy link
Member

nrc commented Aug 10, 2016

r=me with those last two things addressed

@cgswords
Copy link
Contributor Author

Addressed.

@nrc
Copy link
Member

nrc commented Aug 12, 2016

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 12, 2016

📌 Commit 16cc8a7 has been approved by nrc

Manishearth added a commit to Manishearth/rust that referenced this pull request Aug 13, 2016
Implemented a smarter TokenStream concatenation system

The new algorithm performs 'aggressive compacting' during concatenation as follows:

- If the nodes' combined total total length is less than 32, we copy both of
   them into a new vector and build a new leaf node.
- If one node is an internal node and the other is a 'small' leaf (length<32),
   we recur down the internal node on the appropriate side.
 - Otherwise, we construct a new internal node that points to them as left and
 right.

This should produce notably better behavior than the current concatenation implementation.
@eddyb
Copy link
Member

eddyb commented Aug 14, 2016

@bors rollup

eddyb added a commit to eddyb/rust that referenced this pull request Aug 14, 2016
Implemented a smarter TokenStream concatenation system

The new algorithm performs 'aggressive compacting' during concatenation as follows:

- If the nodes' combined total total length is less than 32, we copy both of
   them into a new vector and build a new leaf node.
- If one node is an internal node and the other is a 'small' leaf (length<32),
   we recur down the internal node on the appropriate side.
 - Otherwise, we construct a new internal node that points to them as left and
 right.

This should produce notably better behavior than the current concatenation implementation.
eddyb added a commit to eddyb/rust that referenced this pull request Aug 14, 2016
Implemented a smarter TokenStream concatenation system

The new algorithm performs 'aggressive compacting' during concatenation as follows:

- If the nodes' combined total total length is less than 32, we copy both of
   them into a new vector and build a new leaf node.
- If one node is an internal node and the other is a 'small' leaf (length<32),
   we recur down the internal node on the appropriate side.
 - Otherwise, we construct a new internal node that points to them as left and
 right.

This should produce notably better behavior than the current concatenation implementation.
bors added a commit that referenced this pull request Aug 14, 2016
@bors bors merged commit 16cc8a7 into rust-lang:master Aug 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants