Only freeze once the cached JS values of templates

CParamNodes can be quite large, thus we usually cache the JS::Value when
converting them. The AIInterface makes heavy use of it as detected in #7404.

However, the cached values are re-frozen everytime, which is a
significant waste of time on a large number of templates.

(cherry picked from commit e48b9ea106)
Signed-off-by: Itms <itms@wildfiregames.com>
This commit is contained in:
Itms
2025-01-07 17:14:30 +01:00
parent 13139bba6d
commit beee5b2b8b
3 changed files with 11 additions and 8 deletions
@@ -1,4 +1,4 @@
/* Copyright (C) 2024 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -69,11 +69,6 @@ template<> void Script::ToJSVal<IComponent*>(const ScriptRequest& rq, JS::Mutab
template<> void Script::ToJSVal<CParamNode>(const ScriptRequest& rq, JS::MutableHandleValue ret, CParamNode const& val)
{
val.ToJSVal(rq, true, ret);
// Prevent modifications to the object, so that it's safe to share between
// components and to reconstruct on deserialization
if (ret.isObject())
Script::DeepFreezeObject(rq, ret);
}
template<> void Script::ToJSVal<const CParamNode*>(const ScriptRequest& rq, JS::MutableHandleValue ret, const CParamNode* const& val)