summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej MaƂecki <maciej.malecki@notimplemented.org>2012-06-17 11:50:40 +0200
committerisaacs <i@izs.me>2012-06-17 13:07:20 -0700
commit3db2e034c44ccf6ef10aa8d648f8230f60272595 (patch)
tree61e929d664956619b66d60afc635788ad7f153bf
parent71a2a2caa69865add8065cb0e282096e3f4d78f6 (diff)
downloadnode-3db2e034c44ccf6ef10aa8d648f8230f60272595.tar.gz
events: cache `domain` module locally
It's faster than calling `require` every time we create an `EventEmitter`.
-rw-r--r--lib/events.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/events.js b/lib/events.js
index fe7c04873..7e219a14a 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;
}