Open mathiasbynens opened 8 years ago
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?
Yeah 👍
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. https://github.com/hzoo/babel-plugin-dedupe-string-literals/blob/59db33128a7d9a1f7e09970b69b5346c9673c132/src/index.js#L7 Of course, this assumes theMap
usage isn’t transpiled away before publishing to npm. (Node.js v0.12.14+ supportsMap
; personally I only care about Node.js v6 support since that’s what I use in my build environment.)