(stream, state)
| 25684 | |
| 25685 | // if there's something in the buffer waiting, then process it |
| 25686 | function clearBuffer(stream, state) { |
| 25687 | state.bufferProcessing = true; |
| 25688 | var entry = state.bufferedRequest; |
| 25689 | |
| 25690 | if (stream._writev && entry && entry.next) { |
| 25691 | // Fast case, write everything using _writev() |
| 25692 | var l = state.bufferedRequestCount; |
| 25693 | var buffer = new Array(l); |
| 25694 | var holder = state.corkedRequestsFree; |
| 25695 | holder.entry = entry; |
| 25696 | |
| 25697 | var count = 0; |
| 25698 | while (entry) { |
| 25699 | buffer[count] = entry; |
| 25700 | entry = entry.next; |
| 25701 | count += 1; |
| 25702 | } |
| 25703 | |
| 25704 | doWrite(stream, state, true, state.length, buffer, '', holder.finish); |
| 25705 | |
| 25706 | // doWrite is almost always async, defer these to save a bit of time |
| 25707 | // as the hot path ends with doWrite |
| 25708 | state.pendingcb++; |
| 25709 | state.lastBufferedRequest = null; |
| 25710 | if (holder.next) { |
| 25711 | state.corkedRequestsFree = holder.next; |
| 25712 | holder.next = null; |
| 25713 | } else { |
| 25714 | state.corkedRequestsFree = new CorkedRequest(state); |
| 25715 | } |
| 25716 | } else { |
| 25717 | // Slow case, write chunks one-by-one |
| 25718 | while (entry) { |
| 25719 | var chunk = entry.chunk; |
| 25720 | var encoding = entry.encoding; |
| 25721 | var cb = entry.callback; |
| 25722 | var len = state.objectMode ? 1 : chunk.length; |
| 25723 | |
| 25724 | doWrite(stream, state, false, len, chunk, encoding, cb); |
| 25725 | entry = entry.next; |
| 25726 | // if we didn't call the onwrite immediately, then |
| 25727 | // it means that we need to wait until it does. |
| 25728 | // also, that means that the chunk and cb are currently |
| 25729 | // being processed, so move the buffer counter past them. |
| 25730 | if (state.writing) { |
| 25731 | break; |
| 25732 | } |
| 25733 | } |
| 25734 | |
| 25735 | if (entry === null) state.lastBufferedRequest = null; |
| 25736 | } |
| 25737 | |
| 25738 | state.bufferedRequestCount = 0; |
| 25739 | state.bufferedRequest = entry; |
| 25740 | state.bufferProcessing = false; |
| 25741 | } |
| 25742 | |
| 25743 | Writable.prototype._write = function (chunk, encoding, cb) { |
no test coverage detected