bloomfilter
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -44,5 +44,4 @@ (function(exports) { | ||
b = fnv_1a_b(a), | ||
i = -1, | ||
x = a % m; | ||
while (++i < k) { | ||
for (var i = 0; i < k; ++i) { | ||
r[i] = x < 0 ? (x + m) : x; | ||
@@ -56,6 +55,5 @@ x = (x + b) % m; | ||
var l = this.locations(v + ""), | ||
i = -1, | ||
k = this.k, | ||
buckets = this.buckets; | ||
while (++i < k) buckets[Math.floor(l[i] / 32)] |= 1 << (l[i] % 32); | ||
for (var i = 0; i < k; ++i) buckets[Math.floor(l[i] / 32)] |= 1 << (l[i] % 32); | ||
}; | ||
@@ -65,8 +63,6 @@ | ||
var l = this.locations(v + ""), | ||
i = -1, | ||
k = this.k, | ||
b, | ||
buckets = this.buckets; | ||
while (++i < k) { | ||
b = l[i]; | ||
for (var i = 0; i < k; ++i) { | ||
var b = l[i]; | ||
if ((buckets[Math.floor(b / 32)] & (1 << (b % 32))) === 0) { | ||
@@ -91,3 +87,3 @@ return false; | ||
v = (v & 0x33333333) + ((v >> 2) & 0x33333333); | ||
return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; | ||
return ((v + (v >> 4) & 0xf0f0f0f) * 0x1010101) >> 24; | ||
} | ||
@@ -101,9 +97,4 @@ | ||
d = c & 0xff00; | ||
if (d) { | ||
a ^= d >> 8; | ||
a += (a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24); | ||
} | ||
a ^= c & 0xff; | ||
// a = a * 16777619 mod 2**32 | ||
a += (a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24); | ||
if (d) a = fnv_multiply(a ^ d >> 8); | ||
a = fnv_multiply(a ^ c & 0xff); | ||
} | ||
@@ -113,5 +104,10 @@ return fnv_mix(a); | ||
// a * 16777619 mod 2**32 | ||
function fnv_multiply(a) { | ||
return a + (a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24); | ||
} | ||
// One additional iteration of FNV, given a hash. | ||
function fnv_1a_b(a) { | ||
return fnv_mix(a + (a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24)); | ||
return fnv_mix(fnv_multiply(a)); | ||
} | ||
@@ -122,5 +118,5 @@ | ||
a += a << 13; | ||
a ^= a >> 7; | ||
a ^= a >>> 7; | ||
a += a << 3; | ||
a ^= a >> 17; | ||
a ^= a >>> 17; | ||
a += a << 5; | ||
@@ -127,0 +123,0 @@ return a & 0xffffffff; |
{ | ||
"name": "bloomfilter", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "Fast bloom filter in JavaScript.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8514
148