Cache message JS conversions, to make broadcasts faster

This was SVN commit r8120.
This commit is contained in:
Ykkrosh
2010-09-17 17:49:39 +00:00
parent bd38d9d34f
commit db047e5bee
4 changed files with 16 additions and 4 deletions
@@ -53,9 +53,7 @@ void CComponentTypeScript::HandleMessage(const CSimContext& UNUSED(context), con
{
const char* name = global ? msg.GetScriptGlobalHandlerName() : msg.GetScriptHandlerName();
CScriptVal msgVal = msg.ToJSVal(m_ScriptInterface);
// TODO: repeated conversions are exceedingly inefficient. Should
// cache this once per message (if it's used by >= 1 scripted component)
CScriptVal msgVal = msg.ToJSValCached(m_ScriptInterface);
if (!m_ScriptInterface.CallFunctionVoid(m_Instance, name, msgVal))
LOGERROR(L"Script message handler %hs failed", name);