electron-userland / electron-spellchecker

Implement spellchecking, correctly
MIT License
239 stars 83 forks source link

The LRUCache is too small! #136

Closed bengotow closed 5 years ago

bengotow commented 5 years ago

On macOS, querying the native module for whether a word is misspelled is not free - in fact, it's pretty slow. Because of this, this module implements an LRU cache here: https://github.com/electron-userland/electron-spellchecker/blob/master/src/spell-check-handler.js#L130.

However:

The latter is a big problem - if you type more than 512 words in your text box / app, performance starts to degrade fairly linearly because all but 512 lookups will always be cache misses. Given that we're just storing booleans, I think a cache size of ~5000 would be more reasonable and accommodate writing a whole email, for example!