1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 12:52:28 +01:00

autocommands: some optimization applied

This commit is contained in:
Konstantin Stepanov
2008-08-25 23:16:30 +00:00
parent 6cf70a5984
commit a57b0b5673

View File

@@ -127,11 +127,13 @@ liberator.AutoCommands = function () //{{{
var flag = true; var flag = true;
for (var y = 0; y < autoCommands[eventsIter[i]].length; y++) for (var y = 0; y < autoCommands[eventsIter[i]].length; y++)
{ {
if (autoCommands[eventsIter[i]][y][0] == regex && autoCommands[eventsIter[i]][y][1] == cmds) if (autoCommands[eventsIter[i]][y][0] == regex && autoCommands[eventsIter[i]][y][1] == cmds) {
flag = false; flag = false;
break;
}
} }
if (flag) if (flag)
autoCommands[eventsIter[i]].push([regex, cmds]); autoCommands[eventsIter[i]].push([regex, cmds, new RegExp(regex)]);
} }
}, },
@@ -221,8 +223,7 @@ liberator.AutoCommands = function () //{{{
{ {
for (var i = 0; i < autoCommands[auEvent].length; i++) for (var i = 0; i < autoCommands[auEvent].length; i++)
{ {
var regex = new RegExp(autoCommands[auEvent][i][0]); if (autoCommands[auEvent][i][2].test(url))
if (regex.test(url))
liberator.execute(autoCommands[auEvent][i][1]); liberator.execute(autoCommands[auEvent][i][1]);
} }
} }