summaryrefslogtreecommitdiff
path: root/std/hash/_fnv/util.ts
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2021-02-02 19:05:46 +0800
committerGitHub <noreply@github.com>2021-02-02 12:05:46 +0100
commit6abf126c2a7a451cded8c6b5e6ddf1b69c84055d (patch)
treefd94c013a19fcb38954844085821ec1601c20e18 /std/hash/_fnv/util.ts
parenta2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (diff)
chore: remove std directory (#9361)
This removes the std folder from the tree. Various parts of the tests are pretty tightly dependent on std (47 direct imports and 75 indirect imports, not counting the cli tests that use them as fixtures) so I've added std as a submodule for now.
Diffstat (limited to 'std/hash/_fnv/util.ts')
-rw-r--r--std/hash/_fnv/util.ts52
1 files changed, 0 insertions, 52 deletions
diff --git a/std/hash/_fnv/util.ts b/std/hash/_fnv/util.ts
deleted file mode 100644
index 8afed8e82..000000000
--- a/std/hash/_fnv/util.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-
-function n16(n: number): number {
- return n & 0xffff;
-}
-
-function n32(n: number): number {
- return n >>> 0;
-}
-
-function add32WithCarry(a: number, b: number): [number, number] {
- const added = n32(a) + n32(b);
- return [n32(added), added > 0xffffffff ? 1 : 0];
-}
-
-function mul32WithCarry(a: number, b: number): [number, number] {
- const al = n16(a);
- const ah = n16(a >>> 16);
- const bl = n16(b);
- const bh = n16(b >>> 16);
-
- const [t, tc] = add32WithCarry(al * bh, ah * bl);
- const [n, nc] = add32WithCarry(al * bl, n32(t << 16));
- const carry = nc + (tc << 16) + n16(t >>> 16) + ah * bh;
-
- return [n, carry];
-}
-
-/**
- * mul32 performs 32-bit multiplication, a * b
- * @param a
- * @param b
- */
-export function mul32(a: number, b: number): number {
- // https://stackoverflow.com/a/28151933
- const al = n16(a);
- const ah = a - al;
- return n32(n32(ah * b) + al * b);
-}
-
-/**
- * mul64 performs 64-bit multiplication with two 32-bit words
- * @param [ah, al]
- * @param [bh, bl]
- */
-export function mul64(
- [ah, al]: [number, number],
- [bh, bl]: [number, number],
-): [number, number] {
- const [n, c] = mul32WithCarry(al, bl);
- return [n32(mul32(al, bh) + mul32(ah, bl) + c), n];
-}