Right now the [patch] implementation of proc-macro2 hasn't really been optimized at all, it's basically the fallback implementation in proc-macro2 itself. There's a number of aspects to it that may cause macros to be slower than they otherwise should be:
TokenStream is simply a Vec, so Clone is expensive
Both Ident and Literal store an internal String, so cloning is expensive
That may actually be it now that I think about it... I might be worthwhile investigating interning and/or Rc<Vec<TokenTree>> for wasm.
Right now the
[patch]
implementation ofproc-macro2
hasn't really been optimized at all, it's basically the fallback implementation inproc-macro2
itself. There's a number of aspects to it that may cause macros to be slower than they otherwise should be:TokenStream
is simply aVec
, soClone
is expensiveIdent
andLiteral
store an internalString
, so cloning is expensiveThat may actually be it now that I think about it... I might be worthwhile investigating interning and/or
Rc<Vec<TokenTree>>
for wasm.