| 7001 | // This function is designed to be inlinable, so please take care when making |
| 7002 | // changes to the function body. |
| 7003 | function copyFromBufferString(n, list) { |
| 7004 | var p = list.head; |
| 7005 | var c = 1; |
| 7006 | var ret = p.data; |
| 7007 | n -= ret.length; |
| 7008 | while (p = p.next) { |
| 7009 | var str = p.data; |
| 7010 | var nb = n > str.length ? str.length : n; |
| 7011 | if (nb === str.length) ret += str;else ret += str.slice(0, n); |
| 7012 | n -= nb; |
| 7013 | if (n === 0) { |
| 7014 | if (nb === str.length) { |
| 7015 | ++c; |
| 7016 | if (p.next) list.head = p.next;else list.head = list.tail = null; |
| 7017 | } else { |
| 7018 | list.head = p; |
| 7019 | p.data = str.slice(nb); |
| 7020 | } |
| 7021 | break; |
| 7022 | } |
| 7023 | ++c; |
| 7024 | } |
| 7025 | list.length -= c; |
| 7026 | return ret; |
| 7027 | } |
| 7028 | |
| 7029 | // Copies a specified amount of bytes from the list of buffered data chunks. |
| 7030 | // This function is designed to be inlinable, so please take care when making |