Repository navigation
Commit ca45ad4
committed
stream: read sync sources synchronously in stream/iter pipeTo()
pipeTo() iterated the from() normalization of a sync iterable source
with for await...of, which costs three promises and several ticks per
batch, even though the batches are read synchronously.
Let the iterator returned by from() for a sync iterable read the next
batch synchronously when no operation is running or queued and the
value read needs no asynchronous normalization, and have pipeTo() use it
when there are no transforms and no signal. Other values are normalized
through next() as before, a write error still closes the source, and an
error reading the source still does not.
The source and the writer see the same calls in the same order; the
batches are no longer written on separate ticks unless a write is
asynchronous. Piping a sync generator yielding 16-byte chunks, one per
batch, is about 2.5 times faster, the same as pipeToSync().
Assisted-by: OpenCode1 parent 3c7362f commit ca45ad4
4 files changed
Lines changed: 137 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
142 | 147 | | |
143 | 148 | | |
144 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
145 | 172 | | |
146 | 173 | | |
147 | 174 | | |
| |||
938 | 965 | | |
939 | 966 | | |
940 | 967 | | |
941 | | - | |
| 968 | + | |
942 | 969 | | |
943 | 970 | | |
944 | 971 | | |
| |||
1063 | 1090 | | |
1064 | 1091 | | |
1065 | 1092 | | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
1066 | 1118 | | |
1067 | 1119 | | |
1068 | 1120 | | |
1069 | 1121 | | |
| 1122 | + | |
1070 | 1123 | | |
1071 | 1124 | | |
1072 | 1125 | | |
| |||
1290 | 1343 | | |
1291 | 1344 | | |
1292 | 1345 | | |
| 1346 | + | |
1293 | 1347 | | |
1294 | 1348 | | |
1295 | 1349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
1708 | 1709 | | |
1709 | 1710 | | |
1710 | 1711 | | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
1711 | 1740 | | |
1712 | 1741 | | |
1713 | 1742 | | |
| |||
1767 | 1796 | | |
1768 | 1797 | | |
1769 | 1798 | | |
| 1799 | + | |
| 1800 | + | |
1770 | 1801 | | |
1771 | 1802 | | |
1772 | 1803 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
567 | 571 | | |
568 | 572 | | |
569 | 573 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
348 | 394 | | |
349 | 395 | | |
350 | 396 | | |
| |||
365 | 411 | | |
366 | 412 | | |
367 | 413 | | |
| 414 | + | |
368 | 415 | | |
369 | 416 | | |
0 commit comments