Fix #186 unnecessary if statement inside while loop

This commit is contained in:
Faisal Salman 2016-11-22 00:49:18 +07:00
parent 01ae611dfa
commit 2aa2f77881

View File

@ -83,33 +83,26 @@
rgx : function () { rgx : function () {
var result, i = 0, j, k, p, q, matches, match, args = arguments; var result = {}, i = 0, j, k, p, q, matches, match, args = arguments;
// construct object barebones
for (p = 0; p < args[1].length; p++) {
q = args[1][p];
result[typeof q === OBJ_TYPE ? q[0] : q] = undefined;
}
// loop through all regexes maps // loop through all regexes maps
while (i < args.length && !matches) { while (i < args.length && !matches) {
var regex = args[i], // even sequence (0,2,4,..) var regex = args[i], // even sequence (0,2,4,..)
props = args[i + 1]; // odd sequence (1,3,5,..) props = args[i + 1]; // odd sequence (1,3,5,..)
j = k = 0;
// construct object barebones
if (typeof result === UNDEF_TYPE) {
result = {};
for (p in props) {
if (props.hasOwnProperty(p)){
q = props[p];
if (typeof q === OBJ_TYPE) {
result[q[0]] = undefined;
} else {
result[q] = undefined;
}
}
}
}
// try matching uastring with regexes // try matching uastring with regexes
j = k = 0;
while (j < regex.length && !matches) { while (j < regex.length && !matches) {
matches = regex[j++].exec(this.getUA()); matches = regex[j++].exec(this.getUA());
if (!!matches) { if (!!matches) {
for (p = 0; p < props.length; p++) { for (p = 0; p < props.length; p++) {
match = matches[++k]; match = matches[++k];