net: Don't go through Stream API when ondata is used
This speeds up http_simple by around 6%.
This commit is contained in:
parent
f423287453
commit
e11668b244
@ -461,7 +461,10 @@ function onread(buffer, offset, length) {
|
|||||||
// if it's not enough data, we'll just call handle.readStart()
|
// if it's not enough data, we'll just call handle.readStart()
|
||||||
// again right away.
|
// again right away.
|
||||||
self.bytesRead += length;
|
self.bytesRead += length;
|
||||||
self._readableState.onread(null, buffer.slice(offset, end));
|
|
||||||
|
// Optimization: emit the original buffer with end points
|
||||||
|
if (self.ondata) self.ondata(buffer, offset, end);
|
||||||
|
else self._readableState.onread(null, buffer.slice(offset, end));
|
||||||
|
|
||||||
if (handle.reading && !self._readableState.reading) {
|
if (handle.reading && !self._readableState.reading) {
|
||||||
handle.reading = false;
|
handle.reading = false;
|
||||||
@ -471,9 +474,6 @@ function onread(buffer, offset, length) {
|
|||||||
self._destroy(errnoException(errno, 'read'));
|
self._destroy(errnoException(errno, 'read'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optimization: emit the original buffer with end points
|
|
||||||
if (self.ondata) self.ondata(buffer, offset, end);
|
|
||||||
|
|
||||||
} else if (errno == 'EOF') {
|
} else if (errno == 'EOF') {
|
||||||
debug('EOF');
|
debug('EOF');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user