Minor code review

This commit is contained in:
Raymond Hill 2023-10-10 13:30:18 -04:00
parent 3a5606125d
commit f15dff27fe
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 34 additions and 30 deletions

View File

@ -2643,39 +2643,43 @@ class FilterBucket extends FilterCollection {
} }
static optimize(idata, optimizeBits = 0b11) { static optimize(idata, optimizeBits = 0b11) {
if ( filterData[idata+2] >= 3 && (optimizeBits & 0b01) !== 0 ) { if ( (optimizeBits & 0b01) !== 0 ) {
const iplaintrie = this.optimizePatternTests(idata); if ( filterData[idata+2] >= 3 ) {
if ( iplaintrie !== 0 ) { const iplaintrie = this.optimizePatternTests(idata);
const icollection = filterData[idata+1]; if ( iplaintrie !== 0 ) {
const i = filterData[icollection+1]; const icollection = filterData[idata+1];
if ( i === 0 ) { return iplaintrie; } const i = filterData[icollection+1];
this.unshift(idata, iplaintrie); if ( i === 0 ) { return iplaintrie; }
this.unshift(idata, iplaintrie);
}
} }
} }
if ( filterData[idata+2] >= 5 && (optimizeBits & 0b10) !== 0 ) { if ( (optimizeBits & 0b10) !== 0 ) {
const ioptimized = this.optimizeMatch( if ( filterData[idata+2] >= 5 ) {
idata, const ioptimized = this.optimizeMatch(
FilterBucketIfOriginHits, idata,
5 FilterBucketIfOriginHits,
); 5
if ( ioptimized !== 0 ) { );
const icollection = filterData[idata+1]; if ( ioptimized !== 0 ) {
const i = filterData[icollection+1]; const icollection = filterData[idata+1];
if ( i === 0 ) { return ioptimized; } const i = filterData[icollection+1];
this.unshift(idata, ioptimized); if ( i === 0 ) { return ioptimized; }
this.unshift(idata, ioptimized);
}
} }
} if ( filterData[idata+2] >= 5 ) {
if ( filterData[idata+2] >= 5 && (optimizeBits & 0b10) !== 0 ) { const ioptimized = this.optimizeMatch(
const ioptimized = this.optimizeMatch( idata,
idata, FilterBucketIfRegexHits,
FilterBucketIfRegexHits, 5
5 );
); if ( ioptimized !== 0 ) {
if ( ioptimized !== 0 ) { const icollection = filterData[idata+1];
const icollection = filterData[idata+1]; const i = filterData[icollection+1];
const i = filterData[icollection+1]; if ( i === 0 ) { return ioptimized; }
if ( i === 0 ) { return ioptimized; } this.unshift(idata, ioptimized);
this.unshift(idata, ioptimized); }
} }
} }
return 0; return 0;