Don't have much data yet about why the variable is being set so often, however I noticed this reading through the code:
And drupal_clear_js_cache() does this:
So this means:
- a cache clear sets the variable to an empty array.
- each time a file is found it's parsed for translations
- each time a file is found, a refresh flag gets set so that all previously parsed files are parsed again.
The latter seems unnecessary to me - if you're adding new files, then you're deploying code and likely clearing caches anyway. When the entire variable is reset, we don't need to keep refreshing it just when new files are pulled up.
No patch yet.