From 3db2e034c44ccf6ef10aa8d648f8230f60272595 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Maciej=20Ma=C5=82ecki?= Date: Sun, 17 Jun 2012 11:50:40 +0200 Subject: [PATCH] events: cache `domain` module locally It's faster than calling `require` every time we create an `EventEmitter`. --- lib/events.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/events.js b/lib/events.js index fe7c048..7e219a1 100644 --- a/lib/events.js +++ b/lib/events.js @@ -20,11 +20,12 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. var isArray = Array.isArray; +var domain; function EventEmitter() { if (exports.usingDomains) { // if there is an active domain, then attach to it. - var domain = require('domain'); + domain = domain || require('domain'); if (domain.active && !(this instanceof domain.Domain)) { this.domain = domain.active; } -- 2.7.4