Misc performance improvements for utility functions

fork
Brian White 12 years ago
parent 21e50a9887
commit f9c72c9323

@ -169,12 +169,12 @@ exports.bufferIndexOf = function(buf, str, start) {
searchLen = search.length,
ret = -1, i, j, len;
for (i=start||0,len=buf.length; i<len; ++i) {
if (buf[i] == search[0] && (len-i) >= searchLen) {
if (buf[i] === search[0] && (len-i) >= searchLen) {
if (searchLen > 1) {
for (j=1; j<searchLen; ++j) {
if (buf[i+j] != search[j])
if (buf[i+j] !== search[j])
break;
else if (j == searchLen-1) {
else if (j === searchLen - 1) {
ret = i;
break;
}
@ -243,8 +243,11 @@ exports.buildSearchQuery = function(options, extensions, isOrChild) {
if (criteria === 'OR') {
if (args.length !== 2)
throw new Error('OR must have exactly two arguments');
searchargs += ' OR (' + buildSearchQuery(args[0], extensions, true) + ') ('
+ buildSearchQuery(args[1], extensions, true) + ')'
searchargs += ' OR (';
searchargs += buildSearchQuery(args[0], extensions, true);
searchargs += ') (';
searchargs += buildSearchQuery(args[1], extensions, true);
searchargs += ')';
} else {
if (criteria[0] === '!') {
modifier += 'NOT ';

Loading…
Cancel
Save