Skip to content

Commit

Permalink
Optimize environment lookup to happen once only
Browse files Browse the repository at this point in the history
`process.env` lookup results in a synchronous syscall to `getenv()`,
thus should be avoided in hot code.

Add `request.debug` to allow setting debugging mode at runtime.
  • Loading branch information
mmalecki committed Jan 3, 2013
1 parent f78f32b commit b85bf63
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Request.prototype.init = function (options) {
var self = this

if (!options) options = {}
if (process.env.NODE_DEBUG && /request/.test(process.env.NODE_DEBUG)) console.error('REQUEST', options)
if (request.debug) console.error('REQUEST', options)
if (!self.pool && self.pool !== false) self.pool = globalPool
self.dests = self.dests || []
self.__isRequestRequest = true
Expand Down Expand Up @@ -1004,6 +1004,8 @@ function request (uri, options, callback) {

module.exports = request

request.debug = process.env.NODE_DEBUG && /request/.test(process.env.NODE_DEBUG)

request.initParams = initParams

request.defaults = function (options, requester) {
Expand Down

0 comments on commit b85bf63

Please sign in to comment.