dpcsuresh / scriptno

Automatically exported from code.google.com/p/scriptno
0 stars 0 forks source link

Pages are slow to load when Antisocial mode is set and Unwanted Content is blocked. #245

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

After I installed ScriptSafe, I noticed that every web pages I opened took a 
lot of time to load (at least 10s!). So I started to play with the options, and 
found out that when the Antisocial mode was set and the Unwanted Content is 
blocked, the page load time was huge, while when none of these options were 
set, the page load time was the same as before (~2-3s). I then looked at the 
source code, and realized that the way websites are categorized as "Antisocial" 
or "Unwanted" is not optimized at all: the address of each element on every web 
pages is looked up in multiple lists, resulting in more than 22000 string 
comparisons for each element.

In order to speed up the look up, I changed the source code so that the 
blacklists are converted to hash tables (i.e., associative arrays) with O(1) 
search operations (vs O(n) with simple lists). I also converted the multiple 
hard coded Antisocial URL comparisons into a single regular expression test. 
Now, web pages load as fast as before, with both options set.

The attached patch shows the changes. Please, consider applying it.

Original issue reported on code.google.com by te...@free.fr on 22 Jan 2014 at 7:45

Attachments: