Skip to content

Commit 1259e07

Browse files
committed
perf: remove flush reassignment
1 parent 7ecac7c commit 1259e07

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ unreleased
1818
- perf: hoist regex declaration
1919
- perf: use regex to extract mime
2020
* perf: enable strict mode
21+
* perf: remove flush reassignment
2122
* perf: simplify threshold detection
2223

2324
1.4.4 / 2015-05-11

index.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ function compression(options) {
5757
var end = res.end
5858
var stream
5959

60-
// flush is noop by default
61-
res.flush = noop;
60+
// flush
61+
res.flush = function flush() {
62+
if (stream) {
63+
stream.flush()
64+
}
65+
}
6266

6367
// proxy
6468

@@ -178,11 +182,6 @@ function compression(options) {
178182
// add bufferred listeners to stream
179183
addListeners(stream, stream.on, listeners)
180184

181-
// overwrite the flush method
182-
res.flush = function(){
183-
stream.flush();
184-
}
185-
186185
// header fields
187186
res.setHeader('Content-Encoding', method);
188187
res.removeHeader('Content-Length');
@@ -232,13 +231,6 @@ function chunkLength(chunk, encoding) {
232231
: chunk.length
233232
}
234233

235-
/**
236-
* No-operation function
237-
* @private
238-
*/
239-
240-
function noop(){}
241-
242234
/**
243235
* Default filter function.
244236
* @private

0 commit comments

Comments
 (0)