mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
perf: pass primitives directly through the context bridge, avoids copying (#24551)
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
This commit is contained in:
@@ -146,6 +146,17 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
|
||||
"deeper than 1000 are not supported.")));
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
}
|
||||
|
||||
// Certain primitives always use the current contexts prototype and we can
|
||||
// pass these through directly which is significantly more performant than
|
||||
// copying them. This list of primitives is based on the classification of
|
||||
// "primitive value" as defined in the ECMA262 spec
|
||||
// https://tc39.es/ecma262/#sec-primitive-value
|
||||
if (value->IsString() || value->IsNumber() || value->IsNullOrUndefined() ||
|
||||
value->IsBoolean() || value->IsSymbol() || value->IsBigInt()) {
|
||||
return v8::MaybeLocal<v8::Value>(value);
|
||||
}
|
||||
|
||||
// Check Cache
|
||||
auto cached_value = object_cache->GetCachedProxiedObject(value);
|
||||
if (!cached_value.IsEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user