ruby-cldr icon indicating copy to clipboard operation
ruby-cldr copied to clipboard

`--merge` should memoize the results for performance

Open movermeyer opened this issue 3 years ago • 0 comments

--merge currently takes a long time, needlessly.

Instead of iterating over each locale in turn and merging in the ancestor locales each time:

en-CA -> en -> root
en-GB -> en -> root
en-US -> en -> root

All of these use the en -> root, which is the same data, so there is no need to recompute those for each child locale.

Instead, you could iterate over the graph of locales breadth-first starting at the root locale, then cache the results for use in the other locales.

(Of course, this might not be worth doing as the whole concept of --merge is likely to change. I just wanted to capture this potential optimization here)

movermeyer avatar Jun 16 '22 16:06 movermeyer