-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
36,104 additions
and
26,029 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"input": ["./assembly/__tests__/*.spec.ts"], | ||
"outDir": "./build", | ||
"suites": [], | ||
"coverage": { | ||
"enabled": true, | ||
"show": false | ||
}, | ||
"reporter": "log", | ||
"buildOptions": { | ||
"args": ["--transform json-as/transform"], | ||
"wasi": true, | ||
"parallel": true, | ||
"verbose": true | ||
}, | ||
"runOptions": { | ||
"runtime": { | ||
"name": "wasmtime", | ||
"run": "wasmtime <file>", | ||
"args": [] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -559,6 +559,5 @@ describe("Should deserialize Objects", () => { | |
}); | ||
|
||
run({ | ||
log: true, | ||
coverage: true | ||
log: true | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Implementation of ATOI. Can be much much faster with SIMD. | ||
*/ | ||
|
||
// @ts-ignore | ||
export function __atoi_fast<T extends number>(str: string, start: u32 = 0, end: u32 = 0): T { | ||
// @ts-ignore | ||
let val: T = 0; | ||
if (!end) end = start + u32(str.length << 1); | ||
if (isSigned<T>()) { | ||
// Negative path | ||
if (load<u16>(changetype<usize>(str) + <usize>start) === 45) { | ||
start += 2; | ||
for (; start < end; start += 2) { | ||
val = (val * 10) + (load<u16>(changetype<usize>(str) + <usize>start) - 48) as T; | ||
} | ||
return -val as T; | ||
} else { | ||
for (; start < end; start += 2) { | ||
val = ((val * 10) + (load<u16>(changetype<usize>(str) + <usize>start) - 48)) as T; | ||
} | ||
return val as T; | ||
} | ||
} else { | ||
for (; start < end; start += 2) { | ||
val = ((val * 10) + (load<u16>(changetype<usize>(str) + <usize>start) - 48)) as T; | ||
} | ||
return val as T; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@inline export function __itoa_fast<T extends number>(buf: usize, val: T): i32 { | ||
if (val > 10000) { | ||
store<u32>(buf, | ||
(((val / 10000) % 10) + 48) | | ||
((((val / 1000) % 10) + 48) << 16), | ||
0 | ||
); | ||
store<u32>(buf, | ||
(((val / 100) % 10) + 48) | | ||
((((val / 10) % 10) + 48) << 16), | ||
4 | ||
); | ||
store<u16>(buf, (val % 10) + 48, 8); | ||
} else if (val > 1000) { | ||
store<u32>(buf, | ||
(((val / 1000) % 10) + 48) | | ||
((((val / 100) % 10) + 48) << 16), | ||
0 | ||
); | ||
store<u32>(buf, | ||
(((val / 10) % 10) + 48) | | ||
(((val % 10) + 48) << 16), | ||
4 | ||
); | ||
} else if (val > 100) { | ||
store<u32>(buf, | ||
(((val / 100) % 10) + 48) | | ||
((((val / 10) % 10) + 48) << 16), | ||
0 | ||
); | ||
store<u16>(buf, | ||
((val % 10) + 48), | ||
4 | ||
); | ||
} else if (val > 10) { | ||
store<u32>(buf, | ||
(((val / 10) % 10) + 48) | | ||
(((val % 10) + 48) << 16), | ||
0 | ||
); | ||
} else { | ||
store<u16>(buf, | ||
val + 48, | ||
0 | ||
); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,10 @@ | ||
import { JSON } from "."; | ||
import { bl } from "./bl"; | ||
/* | ||
@json | ||
class Vec3 { | ||
x: f64 = 1.0; | ||
y: f64 = 2.0; | ||
z: f64 = 3.0; | ||
__SERIALIZE_BL(): void { | ||
bl.write_128(i16x8(123, 34, 120, 34, 58, 49, 44, 34)); /* {"x":1," */ | ||
// bl.write_128(i16x8(121, 34, 58, 50, 44, 34, 122, 34)); /* y":2,"z" */ | ||
// bl.write_32(3342394); /* :3 */ | ||
// bl.write_16(125); /* } */ | ||
// } | ||
//} | ||
//const vec = new Vec3();*/ | ||
JSON.stringifyBL("hello w\"orld!"); | ||
console.log(bl.out<string>())/* | ||
JSON.stringifyBL(vec); | ||
console.log(bl.out<string>())*/ | ||
import { itoa_buffered } from "util/number"; | ||
import { __itoa_fast } from "./custom/itoa"; | ||
|
||
// Usage example | ||
let buf = new ArrayBuffer(10); // 11 characters * 2 bytes per character | ||
const l = __itoa_fast(changetype<usize>(buf), 12345); | ||
console.log(Uint16Array.wrap(buf).join(" ")); | ||
|
||
const len = itoa_buffered(changetype<usize>(buf), 12345); | ||
console.log(Uint16Array.wrap(buf.slice(0, len * 2)).join(" ")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.