From 1a2c1c8a96b4e05d496d05d99f7cf1f7c2fb1829 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 30 Sep 2010 12:16:48 -0700 Subject: [PATCH] Simplify: per-module cache thing --- src/node.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/node.js b/src/node.js index 0f3fb4c45c8..39fcbc6a66a 100644 --- a/src/node.js +++ b/src/node.js @@ -69,18 +69,13 @@ var module = (function () { var Script; var internalModuleCache = {}; + var moduleCache = {}; function Module (id, parent) { this.id = id; this.exports = {}; this.parent = parent; - if (parent) { - this.moduleCache = parent.moduleCache; - } else { - this.moduleCache = {}; - } - this.filename = null; this.loaded = false; this.exited = false; @@ -234,11 +229,11 @@ var module = (function () { throw new Error("Cannot find module '" + request + "'"); } - var cachedModule = parent.moduleCache[filename]; + var cachedModule = moduleCache[filename]; if (cachedModule) return cachedModule.exports; var module = new Module(id, parent); - module.moduleCache[filename] = module; + moduleCache[filename] = module; module.load(filename); return module.exports; };