Greasemonkey: optimize pattern matching a little
Moving `QUrl.toString()` out of the `_match()` function which is called for every pattern in every stript seems to make it ~40% faster.
This commit is contained in:
parent
971b413991
commit
d5d22783ea
@ -196,10 +196,11 @@ class GreasemonkeyManager(QObject):
|
||||
if url.scheme() not in self.greaseable_schemes:
|
||||
return MatchingScripts(url, [], [], [])
|
||||
|
||||
string_url = url.toString(QUrl.FullyEncoded)
|
||||
|
||||
def _match(pattern):
|
||||
# For include and exclude rules if they start and end with '/' they
|
||||
# should be treated as a (ecma syntax) regular expression.
|
||||
string_url = url.toString(QUrl.FullyEncoded)
|
||||
if pattern.startswith('/') and pattern.endswith('/'):
|
||||
matches = re.search(pattern[1:-1], string_url, flags=re.I)
|
||||
return matches is not None
|
||||
|
Loading…
Reference in New Issue
Block a user