mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-16 23:50:02 -04:00
squeeze the last ms of performance out of the rewriter
This commit is contained in:
parent
213f7bfa2b
commit
41acba634d
5 changed files with 31 additions and 152 deletions
|
@ -1,7 +1,8 @@
|
|||
pub mod rewrite;
|
||||
|
||||
use std::str::FromStr;
|
||||
use std::str::{from_utf8, FromStr};
|
||||
|
||||
use js_sys::Uint8Array;
|
||||
use rewrite::rewrite;
|
||||
use url::Url;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
@ -13,12 +14,12 @@ extern "C" {
|
|||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn rewrite_js(js: &str, url: &str) -> String {
|
||||
pub fn rewrite_js(js: &str, url: &str) -> Vec<u8> {
|
||||
rewrite(js, Url::from_str(url).unwrap())
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn rewrite_js_from_arraybuffer(js: &[u8], url: &str) -> String {
|
||||
pub fn rewrite_js_from_arraybuffer(js: &[u8], url: &str) -> Vec<u8> {
|
||||
// technically slower than the c++ string conversion but it will create *less copies*
|
||||
|
||||
let js = unsafe { std::str::from_utf8_unchecked(js) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue