Skip to content
This repository was archived by the owner on Nov 15, 2017. It is now read-only.

Commit cb4dff6

Browse files
committed
more simplifications
1 parent f476660 commit cb4dff6

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

js/abp-filters.js

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -263,31 +263,23 @@ var matchString = function(s) {
263263
token = matches[0];
264264
tokenBeg = matches.index;
265265
tokenEnd = reToken.lastIndex;
266-
prefixKey = tokenBeg > 0 ? s.charAt(matches.index-1) : '0';
267-
suffixKey = tokenEnd < s.length ? s.charAt(tokenEnd) : '0';
268-
269-
if ( tokenBeg > 0 && tokenEnd < sLen ) {
270-
if ( matchFromSomething(s, tokenBeg, tokenEnd, fidx[prefixKey + token + suffixKey]) ||
271-
matchFromSomething(s, tokenBeg, tokenEnd, fidx[prefixKey + token + '0']) ||
272-
matchFromSomething(s, tokenBeg, tokenEnd, fidx['0' + token + suffixKey]) ||
273-
matchFromSomething(s, tokenBeg, tokenEnd, fidx['0' + token + '0']) ) {
266+
prefixKey = tokenBeg > 0 ? s.charAt(matches.index-1) : false;
267+
suffixKey = tokenEnd < sLen ? s.charAt(tokenEnd) : false;
268+
269+
if ( prefixKey && suffixKey ) {
270+
if ( matchFromSomething(s, tokenBeg, tokenEnd, fidx[prefixKey + token + suffixKey]) ) {
274271
return true;
275272
}
276-
continue;
277273
}
278-
if ( tokenBeg > 0 ) {
279-
if ( matchFromSomething(s, tokenBeg, tokenEnd, fidx[prefixKey + token + '0']) ||
280-
matchFromSomething(s, tokenBeg, tokenEnd, fidx['0' + token + '0']) ) {
274+
if ( prefixKey ) {
275+
if ( matchFromSomething(s, tokenBeg, tokenEnd, fidx[prefixKey + token + '0']) ) {
281276
return true;
282277
}
283-
continue;
284278
}
285-
if ( tokenEnd < sLen ) {
286-
if ( matchFromSomething(s, tokenBeg, tokenEnd, fidx['0' + token + suffixKey]) ||
287-
matchFromSomething(s, tokenBeg, tokenEnd, fidx['0' + token + '0']) ) {
279+
if ( suffixKey ) {
280+
if ( matchFromSomething(s, tokenBeg, tokenEnd, fidx['0' + token + suffixKey]) ) {
288281
return true;
289282
}
290-
continue;
291283
}
292284
if ( matchFromSomething(s, tokenBeg, tokenEnd, fidx['0' + token + '0']) ) {
293285
return true;

0 commit comments

Comments
 (0)