[Pkg-javascript-commits] [node-lexical-scope] 58/83: memoize keyOf

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:45:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-lexical-scope.

commit 7b2ba745ec745f3b5c7edcbc90a51ac8f8aeef46
Author: Forbes Lindesay <forbes at lindesay.co.uk>
Date:   Wed Jun 12 22:21:33 2013 +0200

    memoize keyOf
---
 index.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/index.js b/index.js
index 67f7cf0..535cbe3 100644
--- a/index.js
+++ b/index.js
@@ -119,6 +119,7 @@ function idOf (node) {
 }
 
 function keyOf (node) {
+    if (node.lexicalScopeKey) return node.lexicalScopeKey;
     var p = node.parent;
     var ks = objectKeys(p);
     var kv = { keys : [], values : [], top : [] };
@@ -146,7 +147,7 @@ function keyOf (node) {
     if (node.parent.type === 'CallExpression') {
         res.unshift.apply(res, keyOf(node.parent.parent));
     }
-    return res;
+    return node.lexicalScopeKey = res;
 }
 
 var isArray = Array.isArray || function (xs) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-lexical-scope.git



More information about the Pkg-javascript-commits mailing list