hzoo / babel-plugin-dedupe-string-literals

Dedupe strings with new variable declarations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve performance?

mathiasbynens opened this issue · comments

Understandably this tool is slow for large files such as https://raw.githubusercontent.com/mathiasbynens/unicode-8.0.0/15228776965be9ef1af995403b7d47386607318c/bidi-classes/index.js (over 6 MB).

One idea is to use a Map rather than a plain object for the cache, which should result in faster lookups.

Of course, this assumes the Map usage isn’t transpiled away before publishing to npm. (Node.js v0.12.14+ supports Map; personally I only care about Node.js v6 support since that’s what I use in my build environment.)

commented

Yeah I was thinking that too, and right now the key lookup is the value of the string itself

This was mainly for your use case anyway so why not.

We can use package.json engines with Map/Set + make a 2.0

and right now the key lookup is the value of the string itself

I think this is fine now that we use Map. Hashing before the lookup would only make it slower, no?

commented

Yeah 👍