toilscript 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/NOTICE +94 -94
- package/README.md +101 -114
- package/bin/asc.js +0 -0
- package/bin/asinit.js +0 -0
- package/dist/asc.generated.d.ts +10022 -0
- package/dist/asc.js +24457 -0
- package/dist/asc.js.map +7 -0
- package/dist/importmap.json +9 -0
- package/dist/toilscript.generated.d.ts +11237 -0
- package/dist/toilscript.js +337 -0
- package/dist/toilscript.js.map +7 -0
- package/dist/web.js +22 -0
- package/lib/binaryen.d.ts +2 -2
- package/lib/binaryen.js +2 -2
- package/package.json +115 -114
- package/std/README.md +6 -6
- package/std/assembly/array.ts +550 -550
- package/std/assembly/arraybuffer.ts +77 -77
- package/std/assembly/atomics.ts +127 -127
- package/std/assembly/bindings/asyncify.ts +16 -16
- package/std/assembly/bindings/dom.ts +291 -291
- package/std/assembly/bindings/node.ts +6 -6
- package/std/assembly/bitflags.ts +53 -53
- package/std/assembly/builtins.ts +2650 -2650
- package/std/assembly/byteslice.ts +177 -177
- package/std/assembly/compat.ts +2 -2
- package/std/assembly/console.ts +42 -42
- package/std/assembly/crypto.ts +9 -9
- package/std/assembly/dataview.ts +181 -181
- package/std/assembly/date.ts +375 -375
- package/std/assembly/diagnostics.ts +11 -11
- package/std/assembly/encoding.ts +151 -151
- package/std/assembly/endian.ts +45 -45
- package/std/assembly/error.ts +44 -44
- package/std/assembly/fixedarray.ts +173 -173
- package/std/assembly/fixedmap.ts +326 -326
- package/std/assembly/fixedset.ts +275 -275
- package/std/assembly/function.ts +42 -42
- package/std/assembly/index.d.ts +2891 -2891
- package/std/assembly/iterator.ts +35 -35
- package/std/assembly/map.ts +269 -269
- package/std/assembly/math.ts +3289 -3289
- package/std/assembly/memory.ts +123 -123
- package/std/assembly/number.ts +388 -388
- package/std/assembly/object.ts +36 -36
- package/std/assembly/performance.ts +9 -9
- package/std/assembly/pointer.ts +80 -80
- package/std/assembly/polyfills.ts +27 -27
- package/std/assembly/process.ts +50 -50
- package/std/assembly/reference.ts +48 -48
- package/std/assembly/regexp.ts +12 -12
- package/std/assembly/rt/README.md +83 -83
- package/std/assembly/rt/common.ts +81 -81
- package/std/assembly/rt/index-incremental.ts +2 -2
- package/std/assembly/rt/index-memory.ts +1 -1
- package/std/assembly/rt/index-minimal.ts +2 -2
- package/std/assembly/rt/index-stub.ts +1 -1
- package/std/assembly/rt/index.d.ts +37 -37
- package/std/assembly/rt/itcms.ts +419 -419
- package/std/assembly/rt/memory-runtime.ts +94 -94
- package/std/assembly/rt/rtrace.ts +15 -15
- package/std/assembly/rt/stub.ts +133 -133
- package/std/assembly/rt/tcms.ts +254 -254
- package/std/assembly/rt/tlsf.ts +592 -592
- package/std/assembly/rt.ts +90 -90
- package/std/assembly/set.ts +225 -225
- package/std/assembly/shared/feature.ts +68 -68
- package/std/assembly/shared/runtime.ts +13 -13
- package/std/assembly/shared/target.ts +11 -11
- package/std/assembly/shared/tsconfig.json +11 -11
- package/std/assembly/shared/typeinfo.ts +72 -72
- package/std/assembly/staticarray.ts +423 -423
- package/std/assembly/string.ts +850 -850
- package/std/assembly/symbol.ts +114 -114
- package/std/assembly/table.ts +16 -16
- package/std/assembly/tsconfig.json +6 -6
- package/std/assembly/typedarray.ts +1954 -1954
- package/std/assembly/uri.ts +17 -17
- package/std/assembly/util/bytes.ts +107 -107
- package/std/assembly/util/casemap.ts +497 -497
- package/std/assembly/util/error.ts +58 -58
- package/std/assembly/util/hash.ts +117 -117
- package/std/assembly/util/math.ts +1922 -1922
- package/std/assembly/util/memory.ts +290 -290
- package/std/assembly/util/number.ts +873 -873
- package/std/assembly/util/sort.ts +313 -313
- package/std/assembly/util/string.ts +1202 -1202
- package/std/assembly/util/uri.ts +275 -275
- package/std/assembly/vector.ts +4 -4
- package/std/assembly.json +16 -16
- package/std/portable/index.d.ts +461 -461
- package/std/portable/index.js +416 -416
- package/std/portable.json +11 -11
- package/std/types/assembly/index.d.ts +1 -1
- package/std/types/assembly/package.json +2 -2
- package/std/types/portable/index.d.ts +1 -1
- package/std/types/portable/package.json +2 -2
- package/tsconfig-base.json +13 -13
- package/util/README.md +23 -23
- package/util/browser/fs.js +1 -1
- package/util/browser/module.js +5 -5
- package/util/browser/path.js +520 -520
- package/util/browser/process.js +59 -59
- package/util/browser/url.js +23 -23
- package/util/cpu.d.ts +9 -9
- package/util/cpu.js +42 -42
- package/util/find.d.ts +6 -6
- package/util/find.js +20 -20
- package/util/node.d.ts +21 -21
- package/util/node.js +34 -34
- package/util/options.d.ts +70 -70
- package/util/options.js +262 -262
- package/util/terminal.d.ts +52 -52
- package/util/terminal.js +35 -35
- package/util/text.d.ts +26 -26
- package/util/text.js +114 -114
- package/util/tsconfig.json +9 -9
- package/util/web.d.ts +11 -11
- package/util/web.js +33 -33
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
// Common error messages for use across the standard library. Keeping error messages compact
|
|
2
|
-
// and reusing them where possible ensures minimal static data in binaries.
|
|
3
|
-
|
|
4
|
-
// @ts-ignore: decorator
|
|
5
|
-
@lazy @inline
|
|
6
|
-
export const E_INDEXOUTOFRANGE: string = "Index out of range";
|
|
7
|
-
|
|
8
|
-
// @ts-ignore: decorator
|
|
9
|
-
@lazy @inline
|
|
10
|
-
export const E_VALUEOUTOFRANGE: string = "Value out of range";
|
|
11
|
-
|
|
12
|
-
// @ts-ignore: decorator
|
|
13
|
-
@lazy @inline
|
|
14
|
-
export const E_INVALIDLENGTH: string = "Invalid length";
|
|
15
|
-
|
|
16
|
-
// @ts-ignore: decorator
|
|
17
|
-
@lazy @inline
|
|
18
|
-
export const E_EMPTYARRAY: string = "Array is empty";
|
|
19
|
-
|
|
20
|
-
// @ts-ignore: decorator
|
|
21
|
-
@lazy @inline
|
|
22
|
-
export const E_HOLEYARRAY: string = "Element type must be nullable if array is holey";
|
|
23
|
-
|
|
24
|
-
// @ts-ignore: decorator
|
|
25
|
-
@lazy @inline
|
|
26
|
-
export const E_NOTIMPLEMENTED: string = "Not implemented";
|
|
27
|
-
|
|
28
|
-
// @ts-ignore: decorator
|
|
29
|
-
@lazy @inline
|
|
30
|
-
export const E_KEYNOTFOUND: string = "Key does not exist";
|
|
31
|
-
|
|
32
|
-
// @ts-ignore: decorator
|
|
33
|
-
@lazy @inline
|
|
34
|
-
export const E_ALLOCATION_TOO_LARGE: string = "Allocation too large";
|
|
35
|
-
|
|
36
|
-
// @ts-ignore: decorator
|
|
37
|
-
@lazy @inline
|
|
38
|
-
export const E_ALREADY_PINNED: string = "Object already pinned";
|
|
39
|
-
|
|
40
|
-
// @ts-ignore: decorator
|
|
41
|
-
@lazy @inline
|
|
42
|
-
export const E_NOT_PINNED: string = "Object is not pinned";
|
|
43
|
-
|
|
44
|
-
// @ts-ignore: decorator
|
|
45
|
-
@lazy @inline
|
|
46
|
-
export const E_URI_MALFORMED: string = "URI malformed";
|
|
47
|
-
|
|
48
|
-
// @ts-ignore: decorator
|
|
49
|
-
@lazy @inline
|
|
50
|
-
export const E_INVALIDDATE: string = "Invalid Date";
|
|
51
|
-
|
|
52
|
-
// @ts-ignore: decorator
|
|
53
|
-
@lazy @inline
|
|
54
|
-
export const E_UNPAIRED_SURROGATE: string = "Unpaired surrogate";
|
|
55
|
-
|
|
56
|
-
// @ts-ignore: decorator
|
|
57
|
-
@lazy @inline
|
|
58
|
-
export const E_CAPACITYEXCEEDED: string = "Capacity exceeded";
|
|
1
|
+
// Common error messages for use across the standard library. Keeping error messages compact
|
|
2
|
+
// and reusing them where possible ensures minimal static data in binaries.
|
|
3
|
+
|
|
4
|
+
// @ts-ignore: decorator
|
|
5
|
+
@lazy @inline
|
|
6
|
+
export const E_INDEXOUTOFRANGE: string = "Index out of range";
|
|
7
|
+
|
|
8
|
+
// @ts-ignore: decorator
|
|
9
|
+
@lazy @inline
|
|
10
|
+
export const E_VALUEOUTOFRANGE: string = "Value out of range";
|
|
11
|
+
|
|
12
|
+
// @ts-ignore: decorator
|
|
13
|
+
@lazy @inline
|
|
14
|
+
export const E_INVALIDLENGTH: string = "Invalid length";
|
|
15
|
+
|
|
16
|
+
// @ts-ignore: decorator
|
|
17
|
+
@lazy @inline
|
|
18
|
+
export const E_EMPTYARRAY: string = "Array is empty";
|
|
19
|
+
|
|
20
|
+
// @ts-ignore: decorator
|
|
21
|
+
@lazy @inline
|
|
22
|
+
export const E_HOLEYARRAY: string = "Element type must be nullable if array is holey";
|
|
23
|
+
|
|
24
|
+
// @ts-ignore: decorator
|
|
25
|
+
@lazy @inline
|
|
26
|
+
export const E_NOTIMPLEMENTED: string = "Not implemented";
|
|
27
|
+
|
|
28
|
+
// @ts-ignore: decorator
|
|
29
|
+
@lazy @inline
|
|
30
|
+
export const E_KEYNOTFOUND: string = "Key does not exist";
|
|
31
|
+
|
|
32
|
+
// @ts-ignore: decorator
|
|
33
|
+
@lazy @inline
|
|
34
|
+
export const E_ALLOCATION_TOO_LARGE: string = "Allocation too large";
|
|
35
|
+
|
|
36
|
+
// @ts-ignore: decorator
|
|
37
|
+
@lazy @inline
|
|
38
|
+
export const E_ALREADY_PINNED: string = "Object already pinned";
|
|
39
|
+
|
|
40
|
+
// @ts-ignore: decorator
|
|
41
|
+
@lazy @inline
|
|
42
|
+
export const E_NOT_PINNED: string = "Object is not pinned";
|
|
43
|
+
|
|
44
|
+
// @ts-ignore: decorator
|
|
45
|
+
@lazy @inline
|
|
46
|
+
export const E_URI_MALFORMED: string = "URI malformed";
|
|
47
|
+
|
|
48
|
+
// @ts-ignore: decorator
|
|
49
|
+
@lazy @inline
|
|
50
|
+
export const E_INVALIDDATE: string = "Invalid Date";
|
|
51
|
+
|
|
52
|
+
// @ts-ignore: decorator
|
|
53
|
+
@lazy @inline
|
|
54
|
+
export const E_UNPAIRED_SURROGATE: string = "Unpaired surrogate";
|
|
55
|
+
|
|
56
|
+
// @ts-ignore: decorator
|
|
57
|
+
@lazy @inline
|
|
58
|
+
export const E_CAPACITYEXCEEDED: string = "Capacity exceeded";
|
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
export function HASH<T>(key: T): u32 {
|
|
2
|
-
if (isString<T>()) {
|
|
3
|
-
return hashStr(changetype<string>(key));
|
|
4
|
-
} else if (isReference<T>()) {
|
|
5
|
-
if (sizeof<T>() == 4) return hash32(changetype<u32>(key));
|
|
6
|
-
if (sizeof<T>() == 8) return hash64(changetype<u64>(key));
|
|
7
|
-
} else if (isFloat<T>()) {
|
|
8
|
-
if (sizeof<T>() == 4) return hash32(reinterpret<u32>(f32(key)));
|
|
9
|
-
if (sizeof<T>() == 8) return hash64(reinterpret<u64>(f64(key)));
|
|
10
|
-
} else {
|
|
11
|
-
if (sizeof<T>() <= 4) return hash32(u32(key), sizeof<T>());
|
|
12
|
-
if (sizeof<T>() == 8) return hash64(u64(key));
|
|
13
|
-
}
|
|
14
|
-
return unreachable();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// XXHash 32-bit as a starting point, see: https://cyan4973.github.io/xxHash
|
|
18
|
-
|
|
19
|
-
// primes
|
|
20
|
-
// @ts-ignore: decorator
|
|
21
|
-
@inline const XXH32_P1: u32 = 2654435761;
|
|
22
|
-
// @ts-ignore: decorator
|
|
23
|
-
@inline const XXH32_P2: u32 = 2246822519;
|
|
24
|
-
// @ts-ignore: decorator
|
|
25
|
-
@inline const XXH32_P3: u32 = 3266489917;
|
|
26
|
-
// @ts-ignore: decorator
|
|
27
|
-
@inline const XXH32_P4: u32 = 668265263;
|
|
28
|
-
// @ts-ignore: decorator
|
|
29
|
-
@inline const XXH32_P5: u32 = 374761393;
|
|
30
|
-
// @ts-ignore: decorator
|
|
31
|
-
@inline const XXH32_SEED: u32 = 0;
|
|
32
|
-
|
|
33
|
-
// @ts-ignore: decorator
|
|
34
|
-
@inline
|
|
35
|
-
function hash32(key: u32, len: u32 = 4): u32 {
|
|
36
|
-
let h: u32 = XXH32_SEED + XXH32_P5 + len;
|
|
37
|
-
h += key * XXH32_P3;
|
|
38
|
-
h = rotl(h, 17) * XXH32_P4;
|
|
39
|
-
h ^= h >> 15;
|
|
40
|
-
h *= XXH32_P2;
|
|
41
|
-
h ^= h >> 13;
|
|
42
|
-
h *= XXH32_P3;
|
|
43
|
-
h ^= h >> 16;
|
|
44
|
-
return h;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// @ts-ignore: decorator
|
|
48
|
-
@inline
|
|
49
|
-
function hash64(key: u64): u32 {
|
|
50
|
-
let h: u32 = XXH32_SEED + XXH32_P5 + 8;
|
|
51
|
-
h += <u32>key * XXH32_P3;
|
|
52
|
-
h = rotl(h, 17) * XXH32_P4;
|
|
53
|
-
h += <u32>(key >> 32) * XXH32_P3;
|
|
54
|
-
h = rotl(h, 17) * XXH32_P4;
|
|
55
|
-
h ^= h >> 15;
|
|
56
|
-
h *= XXH32_P2;
|
|
57
|
-
h ^= h >> 13;
|
|
58
|
-
h *= XXH32_P3;
|
|
59
|
-
h ^= h >> 16;
|
|
60
|
-
return h;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// @ts-ignore: decorator
|
|
64
|
-
@inline
|
|
65
|
-
function mix(h: u32, key: u32): u32 {
|
|
66
|
-
return rotl(h + key * XXH32_P2, 13) * XXH32_P1;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// @ts-ignore: decorator
|
|
70
|
-
@inline
|
|
71
|
-
function hashStr(key: string): u32 {
|
|
72
|
-
if (changetype<usize>(key) == 0) return XXH32_SEED;
|
|
73
|
-
|
|
74
|
-
let h: u32 = key.length << 1;
|
|
75
|
-
let len: usize = h;
|
|
76
|
-
let pos = changetype<usize>(key);
|
|
77
|
-
|
|
78
|
-
if (len >= 16) {
|
|
79
|
-
let s1 = XXH32_SEED + XXH32_P1 + XXH32_P2;
|
|
80
|
-
let s2 = XXH32_SEED + XXH32_P2;
|
|
81
|
-
let s3 = XXH32_SEED;
|
|
82
|
-
let s4 = XXH32_SEED - XXH32_P1;
|
|
83
|
-
|
|
84
|
-
let end = len + pos - 16;
|
|
85
|
-
while (pos <= end) {
|
|
86
|
-
s1 = mix(s1, load<u32>(pos ));
|
|
87
|
-
s2 = mix(s2, load<u32>(pos, 4));
|
|
88
|
-
s3 = mix(s3, load<u32>(pos, 8));
|
|
89
|
-
s4 = mix(s4, load<u32>(pos, 12));
|
|
90
|
-
pos += 16;
|
|
91
|
-
}
|
|
92
|
-
h += rotl(s1, 1) + rotl(s2, 7) + rotl(s3, 12) + rotl(s4, 18);
|
|
93
|
-
} else {
|
|
94
|
-
h += XXH32_SEED + XXH32_P5;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
let end = changetype<usize>(key) + len - 4;
|
|
98
|
-
while (pos <= end) {
|
|
99
|
-
h += load<u32>(pos) * XXH32_P3;
|
|
100
|
-
h = rotl(h, 17) * XXH32_P4;
|
|
101
|
-
pos += 4;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
end = changetype<usize>(key) + len;
|
|
105
|
-
while (pos < end) {
|
|
106
|
-
h += <u32>load<u8>(pos) * XXH32_P5;
|
|
107
|
-
h = rotl(h, 11) * XXH32_P1;
|
|
108
|
-
pos++;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
h ^= h >> 15;
|
|
112
|
-
h *= XXH32_P2;
|
|
113
|
-
h ^= h >> 13;
|
|
114
|
-
h *= XXH32_P3;
|
|
115
|
-
h ^= h >> 16;
|
|
116
|
-
return h;
|
|
117
|
-
}
|
|
1
|
+
export function HASH<T>(key: T): u32 {
|
|
2
|
+
if (isString<T>()) {
|
|
3
|
+
return hashStr(changetype<string>(key));
|
|
4
|
+
} else if (isReference<T>()) {
|
|
5
|
+
if (sizeof<T>() == 4) return hash32(changetype<u32>(key));
|
|
6
|
+
if (sizeof<T>() == 8) return hash64(changetype<u64>(key));
|
|
7
|
+
} else if (isFloat<T>()) {
|
|
8
|
+
if (sizeof<T>() == 4) return hash32(reinterpret<u32>(f32(key)));
|
|
9
|
+
if (sizeof<T>() == 8) return hash64(reinterpret<u64>(f64(key)));
|
|
10
|
+
} else {
|
|
11
|
+
if (sizeof<T>() <= 4) return hash32(u32(key), sizeof<T>());
|
|
12
|
+
if (sizeof<T>() == 8) return hash64(u64(key));
|
|
13
|
+
}
|
|
14
|
+
return unreachable();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// XXHash 32-bit as a starting point, see: https://cyan4973.github.io/xxHash
|
|
18
|
+
|
|
19
|
+
// primes
|
|
20
|
+
// @ts-ignore: decorator
|
|
21
|
+
@inline const XXH32_P1: u32 = 2654435761;
|
|
22
|
+
// @ts-ignore: decorator
|
|
23
|
+
@inline const XXH32_P2: u32 = 2246822519;
|
|
24
|
+
// @ts-ignore: decorator
|
|
25
|
+
@inline const XXH32_P3: u32 = 3266489917;
|
|
26
|
+
// @ts-ignore: decorator
|
|
27
|
+
@inline const XXH32_P4: u32 = 668265263;
|
|
28
|
+
// @ts-ignore: decorator
|
|
29
|
+
@inline const XXH32_P5: u32 = 374761393;
|
|
30
|
+
// @ts-ignore: decorator
|
|
31
|
+
@inline const XXH32_SEED: u32 = 0;
|
|
32
|
+
|
|
33
|
+
// @ts-ignore: decorator
|
|
34
|
+
@inline
|
|
35
|
+
function hash32(key: u32, len: u32 = 4): u32 {
|
|
36
|
+
let h: u32 = XXH32_SEED + XXH32_P5 + len;
|
|
37
|
+
h += key * XXH32_P3;
|
|
38
|
+
h = rotl(h, 17) * XXH32_P4;
|
|
39
|
+
h ^= h >> 15;
|
|
40
|
+
h *= XXH32_P2;
|
|
41
|
+
h ^= h >> 13;
|
|
42
|
+
h *= XXH32_P3;
|
|
43
|
+
h ^= h >> 16;
|
|
44
|
+
return h;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// @ts-ignore: decorator
|
|
48
|
+
@inline
|
|
49
|
+
function hash64(key: u64): u32 {
|
|
50
|
+
let h: u32 = XXH32_SEED + XXH32_P5 + 8;
|
|
51
|
+
h += <u32>key * XXH32_P3;
|
|
52
|
+
h = rotl(h, 17) * XXH32_P4;
|
|
53
|
+
h += <u32>(key >> 32) * XXH32_P3;
|
|
54
|
+
h = rotl(h, 17) * XXH32_P4;
|
|
55
|
+
h ^= h >> 15;
|
|
56
|
+
h *= XXH32_P2;
|
|
57
|
+
h ^= h >> 13;
|
|
58
|
+
h *= XXH32_P3;
|
|
59
|
+
h ^= h >> 16;
|
|
60
|
+
return h;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// @ts-ignore: decorator
|
|
64
|
+
@inline
|
|
65
|
+
function mix(h: u32, key: u32): u32 {
|
|
66
|
+
return rotl(h + key * XXH32_P2, 13) * XXH32_P1;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// @ts-ignore: decorator
|
|
70
|
+
@inline
|
|
71
|
+
function hashStr(key: string): u32 {
|
|
72
|
+
if (changetype<usize>(key) == 0) return XXH32_SEED;
|
|
73
|
+
|
|
74
|
+
let h: u32 = key.length << 1;
|
|
75
|
+
let len: usize = h;
|
|
76
|
+
let pos = changetype<usize>(key);
|
|
77
|
+
|
|
78
|
+
if (len >= 16) {
|
|
79
|
+
let s1 = XXH32_SEED + XXH32_P1 + XXH32_P2;
|
|
80
|
+
let s2 = XXH32_SEED + XXH32_P2;
|
|
81
|
+
let s3 = XXH32_SEED;
|
|
82
|
+
let s4 = XXH32_SEED - XXH32_P1;
|
|
83
|
+
|
|
84
|
+
let end = len + pos - 16;
|
|
85
|
+
while (pos <= end) {
|
|
86
|
+
s1 = mix(s1, load<u32>(pos ));
|
|
87
|
+
s2 = mix(s2, load<u32>(pos, 4));
|
|
88
|
+
s3 = mix(s3, load<u32>(pos, 8));
|
|
89
|
+
s4 = mix(s4, load<u32>(pos, 12));
|
|
90
|
+
pos += 16;
|
|
91
|
+
}
|
|
92
|
+
h += rotl(s1, 1) + rotl(s2, 7) + rotl(s3, 12) + rotl(s4, 18);
|
|
93
|
+
} else {
|
|
94
|
+
h += XXH32_SEED + XXH32_P5;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let end = changetype<usize>(key) + len - 4;
|
|
98
|
+
while (pos <= end) {
|
|
99
|
+
h += load<u32>(pos) * XXH32_P3;
|
|
100
|
+
h = rotl(h, 17) * XXH32_P4;
|
|
101
|
+
pos += 4;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
end = changetype<usize>(key) + len;
|
|
105
|
+
while (pos < end) {
|
|
106
|
+
h += <u32>load<u8>(pos) * XXH32_P5;
|
|
107
|
+
h = rotl(h, 11) * XXH32_P1;
|
|
108
|
+
pos++;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
h ^= h >> 15;
|
|
112
|
+
h *= XXH32_P2;
|
|
113
|
+
h ^= h >> 13;
|
|
114
|
+
h *= XXH32_P3;
|
|
115
|
+
h ^= h >> 16;
|
|
116
|
+
return h;
|
|
117
|
+
}
|