-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1470 from RReverser/even-faster-strings
Speed up passing ASCII-only strings to WASM
- Loading branch information
Showing
6 changed files
with
102 additions
and
19 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,15 @@ | ||
export function test_string_roundtrip(f) { | ||
const test = expected => { | ||
const actual = f(expected); | ||
if (actual === expected) | ||
return; | ||
throw new Error(`string roundtrip "${actual}" != "${expected}"`); | ||
}; | ||
|
||
test(''); | ||
test('a'); | ||
test('💖'); | ||
|
||
test('a longer string'); | ||
test('a longer 💖 string'); | ||
} |
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,12 @@ | ||
use wasm_bindgen::prelude::*; | ||
use wasm_bindgen_test::*; | ||
|
||
#[wasm_bindgen(module = "/tests/headless/strings.js")] | ||
extern "C" { | ||
fn test_string_roundtrip(c: &Closure<Fn(String) -> String>); | ||
} | ||
|
||
#[wasm_bindgen_test] | ||
fn string_roundtrip() { | ||
test_string_roundtrip(&Closure::wrap(Box::new(|s| s))); | ||
} |
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