31df680789
As its name suggests, `TokenTreeOrTokenTreeSlice` is either a single `TokenTree` or a slice of them. It has methods `len` and `get_tt` that let it be treated much like an ordinary slice. The reason it isn't an ordinary slice is that for `TokenTree::Delimited` the open and close delimiters are represented implicitly, and when they are needed they are constructed on the fly with `Delimited::{open,close}_tt`, rather than being present in memory. This commit changes `Delimited` so the open and close delimiters are represented explicitly. As a result, `TokenTreeOrTokenTreeSlice` is no longer needed and `MatcherPos` and `MatcherTtFrame` can just use an ordinary slice. `TokenTree::{len,get_tt}` are also removed, because they were only needed to support `TokenTreeOrTokenTreeSlice`. The change makes the code shorter and a little bit faster on benchmarks that use macro expansion heavily, partly because `MatcherPos` is a lot smaller (less data to `memcpy`) and partly because ordinary slice operations are faster than `TokenTreeOrTokenTreeSlice::{len,get_tt}`. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |