mirror of https://github.com/gorhill/uBlock.git
just edit comments
This commit is contained in:
parent
5928996f2a
commit
22c460d52f
|
@ -99,9 +99,7 @@ HNTrieBuilder.print = function(trie) {
|
||||||
if ( buf[i] !== 0 ) {
|
if ( buf[i] !== 0 ) {
|
||||||
forks.push(i, indent);
|
forks.push(i, indent);
|
||||||
}
|
}
|
||||||
if ( buf[i+2] !== 0 ) {
|
|
||||||
cc.unshift(buf[i+2]);
|
cc.unshift(buf[i+2]);
|
||||||
}
|
|
||||||
for ( ic = 0; ic < buf[i+3]; ic++ ) {
|
for ( ic = 0; ic < buf[i+3]; ic++ ) {
|
||||||
cc.unshift(buf[i+4+ic]);
|
cc.unshift(buf[i+4+ic]);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +128,7 @@ HNTrieBuilder.print = function(trie) {
|
||||||
www.abc.com
|
www.abc.com
|
||||||
index 01234567890
|
index 01234567890
|
||||||
|
|
||||||
Incorrect matching:
|
Incorrect matching (typically used for plain strings):
|
||||||
index 0123456
|
index 0123456
|
||||||
abc.com
|
abc.com
|
||||||
|
|
|
|
||||||
|
@ -166,9 +164,9 @@ HNTrieBuilder.prototype.add = function(hn) {
|
||||||
this.buf[inext+2] = c; // character code
|
this.buf[inext+2] = c; // character code
|
||||||
this.bufsz += 3;
|
this.bufsz += 3;
|
||||||
if ( c === 0 ) { return; } // character zero is always last cell
|
if ( c === 0 ) { return; } // character zero is always last cell
|
||||||
do { // new branch sprouting made from
|
do {
|
||||||
i = inext; // all characters left to store
|
i = inext; // new branch sprouting made from
|
||||||
ichar -= 1;
|
ichar -= 1; // all characters left to store
|
||||||
c = ichar === -1 ? 0 : hn.charCodeAt(ichar);
|
c = ichar === -1 ? 0 : hn.charCodeAt(ichar);
|
||||||
inext = this.bufsz;
|
inext = this.bufsz;
|
||||||
this.buf[i+1] = inext;
|
this.buf[i+1] = inext;
|
||||||
|
@ -236,22 +234,22 @@ HNTrieBuilder.prototype.matches = function(needle) {
|
||||||
|
|
||||||
Cases, before vacuuming:
|
Cases, before vacuuming:
|
||||||
|
|
||||||
abc.com, abc.org:
|
abc.com, abc.org: 16 cells
|
||||||
*
|
*
|
||||||
_ -- a -- b -- c -- . -- c -- o -- m
|
_ -- a -- b -- c -- . -- c -- o -- m
|
||||||
_ -- a -- b -- c -- . -- o -- r -- g
|
_ -- a -- b -- c -- . -- o -- r -- g
|
||||||
|
|
||||||
abc.com, xyz.com:
|
abc.com, xyz.com: 12 cells
|
||||||
*
|
*
|
||||||
_ -- a -- b -- c -- . -- c -- o -- m
|
_ -- a -- b -- c -- . -- c -- o -- m
|
||||||
_ -- x -- y -- z
|
_ -- x -- y -- z
|
||||||
|
|
||||||
ab.com, b.com:
|
ab.com, b.com: 8 cells
|
||||||
*
|
*
|
||||||
_ -- a -- b -- . -- c -- o -- m
|
_ -- a -- b -- . -- c -- o -- m
|
||||||
_
|
_
|
||||||
|
|
||||||
b.com, ab.com:
|
b.com, ab.com: 8 cells
|
||||||
*
|
*
|
||||||
_ -- b -- . -- c -- o -- m
|
_ -- b -- . -- c -- o -- m
|
||||||
_ -- a
|
_ -- a
|
||||||
|
@ -273,22 +271,22 @@ HNTrieBuilder.prototype.matches = function(needle) {
|
||||||
|
|
||||||
Cases, after vacuuming:
|
Cases, after vacuuming:
|
||||||
|
|
||||||
abc.com, abc.org:
|
abc.com, abc.org: 2 cells
|
||||||
*
|
*
|
||||||
[abc.co]m
|
[abc.co]m
|
||||||
[abc.or]g
|
[abc.or]g
|
||||||
|
|
||||||
abc.com, xyz.com:
|
abc.com, xyz.com: 3 cells
|
||||||
*
|
*
|
||||||
[ab]c -- [.co]m
|
[ab]c -- [.co]m
|
||||||
[xy]z
|
[xy]z
|
||||||
|
|
||||||
ab.com, b.com:
|
ab.com, b.com: 3 cells
|
||||||
*
|
*
|
||||||
a -- [b.co]m
|
a -- [b.co]m
|
||||||
_
|
_
|
||||||
|
|
||||||
b.com, ab.com:
|
b.com, ab.com: 3 cells
|
||||||
*
|
*
|
||||||
_ -- [b.co]m
|
_ -- [b.co]m
|
||||||
a
|
a
|
||||||
|
@ -311,6 +309,11 @@ HNTrieBuilder.prototype.matches = function(needle) {
|
||||||
were added with the current implementation), but so far I do not need this
|
were added with the current implementation), but so far I do not need this
|
||||||
feature.
|
feature.
|
||||||
|
|
||||||
|
TODO: It's possible to build the vacuumed trie on the fly as items are
|
||||||
|
added to it. I need to carefully list all possible cases which can arise
|
||||||
|
at insertion time. The benefits will be: faster creation time (expected), no
|
||||||
|
longer read-only trie (items can be added at any time).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HNTrieBuilder.prototype.vacuum = function() {
|
HNTrieBuilder.prototype.vacuum = function() {
|
||||||
|
|
Loading…
Reference in New Issue