diff --git a/apps/code/variable_box_controller.cpp b/apps/code/variable_box_controller.cpp index 660d7ea7a..ce569135e 100644 --- a/apps/code/variable_box_controller.cpp +++ b/apps/code/variable_box_controller.cpp @@ -225,10 +225,12 @@ void VariableBoxController::loadFunctionsAndVariables(int scriptIndex, const cha bool alreadyInVarBox = false; // TODO Look also in imported nodes - //TODO LEA speed this up with alphabetical search - for (int i = 0; i < k_builtinNodesCount; i++) { - const char * nodeName = m_builtinNodes[i].name(); - int nodeNameLength = m_builtinNodes[i].nameLength(); + // TODO LEA speed this up with alphabetical search + // TODO LEA use numberOfRows() and scriptNodeAtIndex ? + for (int i = 0; i < k_builtinNodesCount + m_currentScriptNodesCount; i++) { + ScriptNode * matchingNode = i < k_builtinNodesCount ? &m_builtinNodes[i] : &m_currentScriptNodes[i - k_builtinNodesCount]; + const char * nodeName = matchingNode->name(); + int nodeNameLength = matchingNode->nameLength(); if ((nodeNameLength < 0 || nodeNameLength == nameLength) && strncmp(nodeName, name, nameLength) == 0) { alreadyInVarBox = true; break;