Always keep filter text index
Background
There is an issue in the UI: https://gitlab.com/eyeo/adblockplus/abpui/adblockplusui/issues/543
The issue occurs mainly because the Set
object for Subscription._filterTextIndex
needs to be initialized when the toggle button is clicked for the first time (as a result of the call to filterStorage.getSubscriptionCount()
). The only clean way around this is to keep the Set
object ready at all times. This would mean adding each filter's text to the Set
in addition to pushing it to the Subscription._filterText
array.
But there's another way: Subscription.updateFilterText()
.
This function is called when a subscription is updated. It already creates the filter text index, but then it discards it to save memory. If it were to keep the index, the index would be available in the next call to Subscription.hasFilterText()
. INIParser
could instead just call Subscription.updateFilterText()
with the entire array of filter text instead of calling Subscription.addFilterText()
for each filter's text.
All in all, this would speed up the parsing of the patterns.ini
while also addressing https://gitlab.com/eyeo/adblockplus/abpui/adblockplusui/issues/543
This change would add ~3 MB to the initial memory footprint, but this was always going to be a tradeoff between memory usage and performance, and it seems there is no free lunch.
What to change
See !138 (closed)
Hints for testers
Same as #10 (closed), but reload the extension itself each time before reloading the page.
Also try the exact steps in #10 (closed) without reloading the extension at all.