Add simple caching of env var lookup

This commit is contained in:
Nick O'Leary 2024-01-05 21:07:20 +00:00
parent c2710f4f6f
commit 54e6d60fe5
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -110,6 +110,10 @@
} }
function getEnvVars (obj, envVars = {}) { function getEnvVars (obj, envVars = {}) {
contextKnownKeys.env = contextKnownKeys.env || {}
if (contextKnownKeys.env[obj.id]) {
return contextKnownKeys.env[obj.id]
}
let parent let parent
if (obj.type === 'tab' || obj.type === 'subflow') { if (obj.type === 'tab' || obj.type === 'subflow') {
RED.nodes.eachConfig(function (conf) { RED.nodes.eachConfig(function (conf) {
@ -130,9 +134,10 @@
envVars[env.name] = obj envVars[env.name] = obj
}) })
} }
contextKnownKeys.env[obj.id] = envVars
return envVars return envVars
} }
RED.pp = getEnvVars
const envAutoComplete = function (val) { const envAutoComplete = function (val) {
const editStack = RED.editor.getEditStack() const editStack = RED.editor.getEditStack()
if (editStack.length === 0) { if (editStack.length === 0) {