Skip to content
Myr

Improve performance for res.json/res.jsonp in most cases

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

closes #2900

authored by Benjamin Tan · committed by Douglas Christopher Wilson · parent b69b760 · Browse files · 2 files+16 added−2 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+16 added−2 removed

  • other:+16 added−2 removed

2 files+16 added−2 removed

modified:lib/response.js+15 added-2 removed
237 unmodified lines
238 // settings239 var app = this.app;240 var replacer = app.get('json replacer');241 var spaces = app.get('json spaces');242 var body = JSON.stringify(val, replacer, spaces);242 var body = stringify(val, replacer, spaces);243244 // content-type245 if (!this.get('Content-Type')) {246 this.set('Content-Type', 'application/json');
33 unmodified lines
280 // settings281 var app = this.app;282 var replacer = app.get('json replacer');283 var spaces = app.get('json spaces');284 var body = JSON.stringify(val, replacer, spaces);284 var body = stringify(val, replacer, spaces);285 var callback = this.req.query[app.get('jsonp callback name')];286287 // content-type288 if (!this.get('Content-Type')) {
761 unmodified lines
10501051 // pipe1052 file.pipe(res);1053}10541055/**1056 * Stringify JSON, like JSON.stringify, but v8 optimized.1057 * @private1058 */10591060function stringify(value, replacer, spaces) {1061 // v8 checks arguments.length for optimizing simple call1062 // https://bugs.chromium.org/p/v8/issues/detail?id=47301063 return replacer || spaces1064 ? JSON.stringify(value, replacer, spaces)1065 : JSON.stringify(value);1066}
modified:History.md+1 added
1unreleased2==========34 * Improve performance for `res.json`/`res.jsonp` in most cases5 * deps: accepts@~1.3.36 - Fix including type extensions in parameters in `Accept` parsing7 - Fix parsing `Accept` parameters with quoted equals8 - Fix parsing `Accept` parameters with quoted semicolons
3088 unmodified lines