Slightly optimize iovec on Windows

This commit is contained in:
Justine Tunney 2024-09-16 21:36:22 -07:00
parent 774c67fcd3
commit 65e425fbca
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
4 changed files with 136 additions and 8 deletions

View file

@ -29,15 +29,21 @@
*/
textwindows size_t __iovec2nt(struct NtIovec iovnt[hasatleast 16],
const struct iovec *iov, size_t iovlen) {
size_t i, limit;
for (limit = 0x7ffff000, i = 0; i < MIN(16, iovlen); ++i) {
iovnt[i].buf = iov[i].iov_base;
size_t i, j, limit = 0x7ffff000;
for (j = i = 0; i < iovlen; ++i) {
if (!iov[i].iov_len)
continue;
if (j == 16)
break;
iovnt[j].buf = iov[i].iov_base;
if (iov[i].iov_len < limit) {
limit -= (iovnt[i].len = iov[i].iov_len);
limit -= (iovnt[j].len = iov[i].iov_len);
++j;
} else {
iovnt[i].len = limit;
iovnt[j].len = limit;
++j;
break;
}
}
return i;
return j;
}