- match every instance of the abbrevation letters appearing in the correct order - score all instances according to matching rules - return maximum score match - add test of maximum score besting first score Matching is done recursively without memoization, resulting in an order of magnitude hit in performance measured in ops/sec. TODO: implement and evaluate potential speedups - calculate the score directly rather than maintain the score array (if the array is not needed for a particular application) - convert recursion to iteration - memoization: store solutions to subproblems (highest scoring choices of character matches over a substring) instead of re-solving them
- add lastScore, lastScoreArray member vars to record results of last match - update tests to access lastScoreArray rather than recomputing match This anticipates the implementation of a more expensive scoring algorithm that returns the maximum score match, rather than the first match.
- add WORD_SEPARATORS config var: an array of characters to treat as word separators - refactor isNewWord() to check for membership in WORD_SEPARATORS array - add tests to cover new separator chars
After returning false on no match case, only one spot where `to` was being optionally used. Simplifies logic of fillArray, and results in a noticable performance speedup.
…dmetal is not a constructor function
This speads up single letter abbreviation misses by up to 10x, and 4 letter misses by ~2x. Updated a few `if (x == 0)` to use `===`, just to be safe.