Truing to use JS `eval' in several ways doesn't seem to be doing

anything for speed.  So dump all attempts at making things faster this
way.  Also, it seems that things are responsive enough with any break in
the searching "thread", so shorten that time.  (And one other random
optimization: abort early when an item doesn't match.)

svn: r16943
This commit is contained in:
Eli Barzilay 2009-11-21 21:53:06 +00:00
parent fbf7f79d8c
commit 128da973df

View File

@ -439,20 +439,21 @@ function Search(data, term, is_pre, K) {
var r, min = C_max, max = C_min;
for (var j=0; j<preds.length; j++) {
r = preds[j](data[i]); min = Math.min(r, min); max = Math.max(r, max);
if (min <= C_min) break; // get out if it's hopeless
}
if (max >= C_rexact && min >= C_exact) exacts.push(data[i]);
else if (min > C_wordmatch) matches.push(data[i]);
else if (min > C_fail) wordmatches.push(data[i]);
fuel--; i++;
}
if (i<data.length) t = setTimeout(DoChunk,15);
if (i<data.length) t = setTimeout(DoChunk,5);
else {
r = [exacts.length, exacts.concat(matches).concat(wordmatches)];
if (K) K(r); else return r;
}
};
if (!K) return DoChunk();
else { progress(0); t = setTimeout(DoChunk,15); return killer; }
else { progress(0); t = setTimeout(DoChunk,5); return killer; }
}
function GetContextHTML() {