scymtym / esrap

Common Lisp packrat parser
https://scymtym.github.io/esrap/
78 stars 12 forks source link

optimize ALIST to HASH-TABLE conversion #17

Closed melisgl closed 1 year ago

melisgl commented 1 year ago

Another micro optimisation.

scymtym commented 1 year ago

If this is a bottleneck, maybe going a bit further and making alist-hash-table/no-dups a macro would be appropriate? The set of supplied hash table initargs is fixed so the make-hash-table call wouldn't need apply and would become optimizable by the implementation. SBCL, for example, analyses the initargs at compile time and directly calls a specialized constructor if possible (Not applicable in this case since :size trips up the compiler macro).

melisgl commented 1 year ago

Bottleneck is a strong word, but it's a ~1% win for MGL-PAX documentation generation. Rewrote it as a macro. Test of Esrap, 3BMD and MGL-PAX all pass.

scymtym commented 1 year ago

Merged, thanks.