mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Removed unnecessary conversion from UTF-8 to UTF-16
This commit is contained in:
parent
916d9e0e3d
commit
6014710538
2 changed files with 8 additions and 13 deletions
|
@ -43,10 +43,10 @@ use html5ever::{LocalName, Prefix};
|
|||
use ipc_channel::ipc;
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::jsapi::{
|
||||
CanCompileOffThread, CompileOffThread, FinishOffThreadScript, Heap, JSScript, OffThreadToken,
|
||||
CanCompileOffThread, CompileOffThread1, FinishOffThreadScript, Heap, JSScript, OffThreadToken,
|
||||
};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::{transform_u16_to_source_text, CompileOptionsWrapper};
|
||||
use js::rust::{transform_str_to_source_text, CompileOptionsWrapper};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::request::{
|
||||
CorsSettings, CredentialsMode, Destination, ParserMetadata, RequestBuilder,
|
||||
|
@ -77,7 +77,6 @@ pub struct OffThreadCompilationContext {
|
|||
task_source: DOMManipulationTaskSource,
|
||||
canceller: TaskCanceller,
|
||||
script_text: String,
|
||||
utf16_chars: Vec<u16>,
|
||||
fetch_options: ScriptFetchOptions,
|
||||
}
|
||||
|
||||
|
@ -433,7 +432,6 @@ impl FetchResponseListener for ClassicContext {
|
|||
|
||||
if can_compile_off_thread {
|
||||
let source_string = source_text.to_string();
|
||||
let source_text: Vec<u16> = source_text.encode_utf16().collect();
|
||||
|
||||
let context = Box::new(OffThreadCompilationContext {
|
||||
script_element: self.elem.clone(),
|
||||
|
@ -443,15 +441,14 @@ impl FetchResponseListener for ClassicContext {
|
|||
task_source: global.dom_manipulation_task_source(),
|
||||
canceller: global.task_canceller(TaskSourceName::DOMManipulation),
|
||||
script_text: source_string,
|
||||
utf16_chars: source_text,
|
||||
fetch_options: self.fetch_options.clone(),
|
||||
});
|
||||
|
||||
unsafe {
|
||||
assert!(CompileOffThread(
|
||||
assert!(CompileOffThread1(
|
||||
*cx,
|
||||
options.ptr as *const _,
|
||||
&mut transform_u16_to_source_text(&context.utf16_chars) as *mut _,
|
||||
&mut transform_str_to_source_text(&context.script_text) as *mut _,
|
||||
Some(off_thread_compilation_callback),
|
||||
Box::into_raw(context) as *mut c_void,
|
||||
));
|
||||
|
|
|
@ -45,7 +45,7 @@ use js::jsapi::Handle as RawHandle;
|
|||
use js::jsapi::HandleObject;
|
||||
use js::jsapi::HandleValue as RawHandleValue;
|
||||
use js::jsapi::Value;
|
||||
use js::jsapi::{CompileModule, ExceptionStackBehavior, FinishDynamicModuleImport};
|
||||
use js::jsapi::{CompileModuleDontInflate, ExceptionStackBehavior, FinishDynamicModuleImport};
|
||||
use js::jsapi::{GetModuleResolveHook, JSRuntime, SetModuleResolveHook};
|
||||
use js::jsapi::{GetRequestedModules, SetModuleMetadataHook};
|
||||
use js::jsapi::{Heap, JSContext, JS_ClearPendingException, SetModulePrivate};
|
||||
|
@ -56,7 +56,7 @@ use js::jsapi::{SetModuleDynamicImportHook, SetScriptPrivateReferenceHooks};
|
|||
use js::jsval::{JSVal, PrivateValue, UndefinedValue};
|
||||
use js::rust::jsapi_wrapped::{GetRequestedModuleSpecifier, JS_GetPendingException};
|
||||
use js::rust::jsapi_wrapped::{JS_GetArrayLength, JS_GetElement};
|
||||
use js::rust::transform_u16_to_source_text;
|
||||
use js::rust::transform_str_to_source_text;
|
||||
use js::rust::wrappers::JS_SetPendingException;
|
||||
use js::rust::CompileOptionsWrapper;
|
||||
use js::rust::{Handle, HandleValue, IntoHandle};
|
||||
|
@ -420,8 +420,6 @@ impl ModuleTree {
|
|||
url: ServoUrl,
|
||||
options: ScriptFetchOptions,
|
||||
) -> Result<ModuleObject, RethrowError> {
|
||||
let module: Vec<u16> = module_script_text.encode_utf16().collect();
|
||||
|
||||
let url_cstr = ffi::CString::new(url.as_str().as_bytes()).unwrap();
|
||||
|
||||
let _ac = JSAutoRealm::new(*global.get_cx(), *global.reflector().get_jsobject());
|
||||
|
@ -430,10 +428,10 @@ impl ModuleTree {
|
|||
unsafe { CompileOptionsWrapper::new(*global.get_cx(), url_cstr.as_ptr(), 1) };
|
||||
|
||||
unsafe {
|
||||
rooted!(in(*global.get_cx()) let mut module_script = CompileModule(
|
||||
rooted!(in(*global.get_cx()) let mut module_script = CompileModuleDontInflate(
|
||||
*global.get_cx(),
|
||||
compile_options.ptr,
|
||||
&mut transform_u16_to_source_text(&module),
|
||||
&mut transform_str_to_source_text(&module_script_text),
|
||||
));
|
||||
|
||||
if module_script.is_null() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue