Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve performance by less data copying
- Loading branch information
Carlos Rodriguez
committed
Aug 29, 2012
1 parent
8c33d7b
commit 874a590
Showing
3 changed files
with
22 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
var parse = require('url').parse; | ||
|
||
// Cached parsed urls. | ||
var cache = {}; | ||
module.exports = function parseUrl (req) { | ||
var parsed = req._parsedUrl; | ||
|
||
module.exports = function parseUrl (url) { | ||
return cache[url] || (cache[url] = parse(url)); | ||
if (parsed && parsed.href == req.url) { | ||
return parsed; | ||
} | ||
else { | ||
return req._parsedUrl = parse(req.url); | ||
} | ||
}; |