summary refs log tree commit diff
path: root/src/libsyntax/ext/tt/transcribe.rs
AgeCommit message (Collapse)AuthorLines
2019-05-28these errors can happen after allMark Mansi-8/+10
2019-05-10turn a couple of fixmes into span_bugsMark Mansi-9/+7
2019-05-08fix incorrect assertMark Mansi-1/+4
2019-05-07lots of comments + minor cleanupMark Mansi-14/+133
2019-05-07avoid extra copyMark Mansi-13/+12
2019-05-06rustfmtMark Mansi-50/+50
2019-02-18Avoid a `clone()` in `transcribe()`.Nicholas Nethercote-2/+1
The current code (expensively) clones the value within an `Rc`. This commit changes things so that the `Rc` itself is (cheaply) cloned instead, avoid some allocations. This requires converting a few `Rc` instances to `Lrc`.
2019-02-18Remove `LazyTokenStream`.Nicholas Nethercote-1/+2
It's present within `Token::Interpolated` as an optimization, so that if a nonterminal is converted to a `TokenStream` multiple times, the first-computed value is saved and reused. But in practice it's not needed. `interpolated_to_tokenstream()` is a cold function: it's only called a few dozen times while compiling rustc itself, and a few hundred times across the entire `rustc-perf` suite. Furthermore, when it is called, it is almost always the first conversion, so no benefit is gained from it. So this commit removes `LazyTokenStream`, along with the now-unnecessary `Token::interpolated()`. As well as a significant simplification, the removal speeds things up slightly, mostly due to not having to `drop` the `LazyTokenStream` instances.
2019-02-07libsyntax => 2018Taiki Endo-11/+12
2019-02-06Overhaul `syntax::fold::Folder`.Nicholas Nethercote-2/+4
This commit changes `syntax::fold::Folder` from a functional style (where most methods take a `T` and produce a new `T`) to a more imperative style (where most methods take and modify a `&mut T`), and renames it `syntax::mut_visit::MutVisitor`. The first benefit is speed. The functional style does not require any reallocations, due to the use of `P::map` and `MoveMap::move_{,flat_}map`. However, every field in the AST must be overwritten; even those fields that are unchanged are overwritten with the same value. This causes a lot of unnecessary memory writes. The imperative style reduces instruction counts by 1--3% across a wide range of workloads, particularly incremental workloads. The second benefit is conciseness; the imperative style is usually more concise. E.g. compare the old functional style: ``` fn fold_abc(&mut self, abc: ABC) { ABC { a: fold_a(abc.a), b: fold_b(abc.b), c: abc.c, } } ``` with the imperative style: ``` fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) { visit_a(a); visit_b(b); } ``` (The reductions get larger in more complex examples.) Overall, the patch removes over 200 lines of code -- even though the new code has more comments -- and a lot of the remaining lines have fewer characters. Some notes: - The old style used methods called `fold_*`. The new style mostly uses methods called `visit_*`, but there are a few methods that map a `T` to something other than a `T`, which are called `flat_map_*` (`T` maps to multiple `T`s) or `filter_map_*` (`T` maps to 0 or 1 `T`s). - `move_map.rs`/`MoveMap`/`move_map`/`move_flat_map` are renamed `map_in_place.rs`/`MapInPlace`/`map_in_place`/`flat_map_in_place` to reflect their slightly changed signatures. - Although this commit renames the `fold` module as `mut_visit`, it keeps it in the `fold.rs` file, so as not to confuse git. The next commit will rename the file.
2019-01-08Make `TokenStream` less recursive.Nicholas Nethercote-3/+3
`TokenStream` is currently recursive in *two* ways: - the `TokenTree` variant contains a `ThinTokenStream`, which can contain a `TokenStream`; - the `TokenStream` variant contains a `Vec<TokenStream>`. The latter is not necessary and causes significant complexity. This commit replaces it with the simpler `Vec<(TokenTree, IsJoint)>`. This reduces complexity significantly. In particular, `StreamCursor` is eliminated, and `Cursor` becomes much simpler, consisting now of just a `TokenStream` and an index. The commit also removes the `Extend` impl for `TokenStream`, because it is only used in tests. (The commit also removes those tests.) Overall, the commit reduces the number of lines of code by almost 200.
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-12Rename `TokenStream::concat` and remove `TokenStream::concat_rc_vec`.Nicholas Nethercote-2/+2
`TokenStream::new` is a better name for the former, and the latter is now just equivalent to `TokenStream::Stream`.
2018-12-10Remove `tokenstream::Delimited`.Nicholas Nethercote-5/+6
Because it's an extra type layer that doesn't really help; in a couple of places it actively gets in the way, and overall removing it makes the code nicer. It does, however, move `tokenstream::TokenTree` further away from the `TokenTree` in `quote.rs`. More importantly, this change reduces the size of `TokenStream` from 48 bytes to 40 bytes on x86-64, which is enough to slightly reduce instruction counts on numerous benchmarks, the best by 1.5%. Note that `open_tt` and `close_tt` have gone from being methods on `Delimited` to associated methods of `TokenTree`.
2018-10-26Remove redundant cloneShotaro Yamada-2/+2
2018-09-26Remove OneVectorljedrz-2/+2
2018-09-08Track distinct spans for open and close delimiterDavid Tolnay-7/+7
2018-08-28Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc.Eduard-Mihai Burtescu-6/+6
2018-08-23Use optimized SmallVec implementationIgor Gutorov-1/+1
2018-08-13Move SmallVec and ThinVec out of libsyntaxljedrz-2/+2
2018-04-06Use `Span::apply_mark` where possibleVadim Petrochenkov-3/+3
2018-04-06Use `Span` instead of `SyntaxContext` in `Ident`Vadim Petrochenkov-1/+1
2018-03-22Clean up raw identifier handling when recovering tokens from AST.Lymia Aluysia-1/+1
2018-03-18Initial implementation of RFC 2151, Raw IdentifiersLymia Aluysia-1/+1
2018-03-02Replace Rc with Lrc for shared dataJohn Kåre Alsaker-3/+4
2017-08-30Make fields of `Span` privateVadim Petrochenkov-3/+3
2017-06-26Add `LazyTokenStream`.Jeffrey Seyfried-1/+1
2017-06-26Simplify `hygiene::Mark` application, andJeffrey Seyfried-26/+34
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-06-08Speed up expansion.Mark Simulacrum-8/+9
This reduces duplication, thereby increasing expansion speed.
2017-05-12Fix some clippy warnings in libsyntaxAndre Bogus-3/+3
This is mostly removing stray ampersands, needless returns and lifetimes.
2017-03-30Improve `Path` spans.Jeffrey Seyfried-8/+1
2017-03-03Integrate `TokenStream`.Jeffrey Seyfried-16/+20
2017-02-28Merge `repeat_idx` and `repeat_len`.Jeffrey Seyfried-17/+15
2017-02-28Remove `Token::MatchNt`.Jeffrey Seyfried-3/+4
2017-02-28Add `syntax::ext::tt::quoted::{TokenTree, ..}` and remove ↵Jeffrey Seyfried-34/+17
`tokenstream::TokenTree::Sequence`.
2017-02-28Avoid `Token::{OpenDelim, CloseDelim}`.Jeffrey Seyfried-16/+22
2017-02-28Remove `ext::tt::transcribe::tt_next_token`.Jeffrey Seyfried-149/+124
2017-02-28Clean up `ext::tt::transcribe::TtFrame`, rename to `Frame`.Jeffrey Seyfried-57/+84
2017-02-28Remove a `loop` in `ext::tt::transcribe`.Jeffrey Seyfried-32/+23
2017-01-17Avoid interpolated token trees.Jeffrey Seyfried-1/+2
2017-01-17Clean up `ext::tt::transcribe`.Jeffrey Seyfried-63/+33
2017-01-17Refactor the parser to consume token trees.Jeffrey Seyfried-4/+7
2016-11-04Remove field `TtReader::next_tok`.Jeffrey Seyfried-5/+0
2016-11-03Move doc comment desugaring into the parser.Jeffrey Seyfried-27/+1
2016-11-03Revert "macros: Improve `tt` fragments"Jeffrey Seyfried-13/+3
This reverts commit 41745f30f751364bdce14428b7d3ffa5dd028903.
2016-11-03Reduce the size of `Token` and make it cheaper to clone by refactoringJeffrey Seyfried-13/+11
`Token::Interpolated(Nonterminal)` -> `Token::Interpolated(Rc<Nonterminal>)`.
2016-10-25Use `SmallVector` for `TtReader::stack`.Nicholas Nethercote-3/+4
This avoids 800,000 heap allocations when compiling html5ever. It requires tweaking `SmallVector` a little.
2016-10-19Improve `$crate`.Jeffrey Seyfried-29/+2
2016-10-17Fix partially consumed tokens in macro matchers.Jeffrey Seyfried-0/+5
2016-08-07Make metavariables hygienic.Jeffrey Seyfried-5/+5