Skip to content
Myr

perf: re-use options object when generating ETags

Before adoption: this commit came in with the history the project adopted, so no landing records it.

closes #3313 closes #3314

authored by Lawrence Page · committed by Douglas Christopher Wilson · parent 02a9d5f · Browse files · 2 files+22 added−14 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+22 added−14 removed

  • other:+22 added−14 removed

2 files+22 added−14 removed

modified:lib/utils.js+21 added-14 removed
29 unmodified lines
30 * @return {String}31 * @api private32 */3334exports.etag = function (body, encoding) {35 var buf = !Buffer.isBuffer(body)36 ? new Buffer(body, encoding)37 : body;34exports.etag = createETagGenerator({ weak: false })3539 return etag(buf, {weak: false});40};4136/**37 * Return weak ETag for `body`.38 *39 * @param {String|Buffer} body
1 unmodified line
41 * @return {String}42 * @api private43 */4451exports.wetag = function wetag(body, encoding){52 var buf = !Buffer.isBuffer(body)53 ? new Buffer(body, encoding)54 : body;45exports.wetag = createETagGenerator({ weak: true })4656 return etag(buf, {weak: true});57};5847/**48 * Check if `path` looks absolute.49 *50 * @param {String} path
210 unmodified lines
261 return contentType.format(parsed);262};263264/**265 * Create an ETag generator function, generating ETags with266 * the given options.267 *268 * @param {object} options269 * @return {function}270 * @private271 */272273function createETagGenerator (options) {274 return function generateETag (body, encoding) {275 var buf = !Buffer.isBuffer(body)276 ? new Buffer(body, encoding)277 : body278279 return etag(buf, options)280 }281}282283/**284 * Parse an extended query string with qs.285 *286 * @return {Object}287 * @private
18 unmodified lines
modified:History.md+1 added
22 unmodified lines
23 * deps: qs@6.5.124 - Fix parsing & compacting very deep objects25 * deps: setprototypeof@1.1.026 * deps: utils-merge@1.0.127 * perf: re-use options object when generating ETags28294.15.5 / 2017-09-2430===================31
3308 unmodified lines