ghostery / ghostery-extension

Ghostery Browser Extension for Firefox, Chrome, Opera, Edge and Safari
Mozilla Public License 2.0
1.34k stars 140 forks source link

fix: use Set over the Array instance for paused hostnames #1662

Closed smalluban closed 1 week ago

smalluban commented 1 week ago

Fixes #1651

Still, I am not sure if this is better. The real question is if Array.prototype.includes is much slower than Set.prototype.has... The list has unique IDs (so no benefit here), and it must be cleared each time, as otherwise, we would need to check if the user removed the domain (and it might be then even slower).

philipp-classen commented 1 week ago

The back-and-forth converting could be avoided, I assume, but modeling the underlying data structure:

paused = [{ id: "foo", ...rest1 }, { id: "bar", ...rest2 }, ...]

as

paused = {
  foo: { ...rest1 },
  bar: { ...rest2 },
  ...
}

But I'm also fine with keeping the array structure if it is difficult to change.

smalluban commented 1 week ago

The dynamic keys are not supported in Store.