From bb1703e1a18e0c967b41e57141d1a3c9a6dd3a2f Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 6 Nov 2015 20:53:12 -0500 Subject: [PATCH] add header comment for scope cache function --- packages/babel-traverse/src/scope/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/babel-traverse/src/scope/index.js b/packages/babel-traverse/src/scope/index.js index a717aa5235..489fc4af6d 100644 --- a/packages/babel-traverse/src/scope/index.js +++ b/packages/babel-traverse/src/scope/index.js @@ -14,10 +14,15 @@ import * as t from "babel-types"; // -const CACHE_SINGLE_KEY = "_scope"; +const CACHE_SINGLE_KEY = "_scope"; //Symbol(); const CACHE_MULTIPLE_KEY = "_scopes"; //Symbol(); -// here we optimise for the case of there being only a single scope associated with a node +/** + * To avoid creating a new Scope instance for each traversal, we maintain a cache on the + * node itself containing all scopes it has been associated with. + * + * We also optimise for the case of there being only a single scope associated with a node. + */ function getCache(node, parentScope, self) { let singleCache = node[CACHE_SINGLE_KEY];