From 12bb77cd9f998e64b352895ea49b3953d48b97f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Tue, 24 Mar 2020 17:16:28 +0100 Subject: [PATCH] [apps/code] Do not import the same current variable twice --- apps/code/variable_box_controller.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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;