forked from 0ad/0ad
Avoid some redundant HasProperty calls.
This was SVN commit r7578.
This commit is contained in:
parent
6fdb947ff0
commit
121d1ead20
@ -27,6 +27,9 @@ CComponentTypeScript::CComponentTypeScript(ScriptInterface& scriptInterface, jsv
|
||||
{
|
||||
debug_assert(instance);
|
||||
m_ScriptInterface.AddRoot(&m_Instance, "CComponentTypeScript.m_Instance");
|
||||
|
||||
// Cache the property detection for efficiency
|
||||
m_HasCustomSerialize = m_ScriptInterface.HasProperty(m_Instance, "Serialize");
|
||||
}
|
||||
|
||||
CComponentTypeScript::~CComponentTypeScript()
|
||||
@ -62,7 +65,7 @@ void CComponentTypeScript::Serialize(ISerializer& serialize)
|
||||
{
|
||||
// Support a custom "Serialize" function, which returns a new object that will be
|
||||
// serialized instead of the component itself
|
||||
if (m_ScriptInterface.HasProperty(m_Instance, "Serialize"))
|
||||
if (m_HasCustomSerialize)
|
||||
{
|
||||
CScriptValRooted val;
|
||||
if (!m_ScriptInterface.CallFunction(m_Instance, "Serialize", val))
|
||||
|
@ -76,6 +76,7 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
private:
|
||||
ScriptInterface& m_ScriptInterface;
|
||||
jsval m_Instance;
|
||||
bool m_HasCustomSerialize;
|
||||
|
||||
NONCOPYABLE(CComponentTypeScript);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user