| 5722 | // This function is designed to be inlinable, so please take care when making |
| 5723 | // changes to the function body. |
| 5724 | function copyFromBufferString(n, list) { |
| 5725 | var p = list.head; |
| 5726 | var c = 1; |
| 5727 | var ret = p.data; |
| 5728 | n -= ret.length; |
| 5729 | while (p = p.next) { |
| 5730 | var str = p.data; |
| 5731 | var nb = n > str.length ? str.length : n; |
| 5732 | if (nb === str.length) ret += str;else ret += str.slice(0, n); |
| 5733 | n -= nb; |
| 5734 | if (n === 0) { |
| 5735 | if (nb === str.length) { |
| 5736 | ++c; |
| 5737 | if (p.next) list.head = p.next;else list.head = list.tail = null; |
| 5738 | } else { |
| 5739 | list.head = p; |
| 5740 | p.data = str.slice(nb); |
| 5741 | } |
| 5742 | break; |
| 5743 | } |
| 5744 | ++c; |
| 5745 | } |
| 5746 | list.length -= c; |
| 5747 | return ret; |
| 5748 | } |
| 5749 | |
| 5750 | // Copies a specified amount of bytes from the list of buffered data chunks. |
| 5751 | // This function is designed to be inlinable, so please take care when making |