diff options
author | Maciej MaĆecki <maciej.malecki@notimplemented.org> | 2012-06-17 11:50:40 +0200 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-06-17 13:07:20 -0700 |
commit | 3db2e034c44ccf6ef10aa8d648f8230f60272595 (patch) | |
tree | 61e929d664956619b66d60afc635788ad7f153bf | |
parent | 71a2a2caa69865add8065cb0e282096e3f4d78f6 (diff) | |
download | node-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.js | 3 |
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; } |