hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit c00757a14ba6d25cf3f38028557d299edef8d5eb
parent 825ffee3ec68e8d65f4075cd5a6fe32b1617319e
Author: Ember Sawady <ecs@d2evs.net>
Date:   Wed,  7 Jun 2023 08:19:02 +0000

io+linux::fd_copy: simplify

Signed-off-by: Ember Sawady <ecs@d2evs.net>

Diffstat:
Mio/+linux/file.ha | 26+++++++-------------------
1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/io/+linux/file.ha b/io/+linux/file.ha @@ -67,26 +67,14 @@ def SENDFILE_MAX: size = 2147479552z; fn fd_copy(to: file, from: file) (size | error) = { let sum = 0z; - for (true) { - let n = match (rt::sendfile(to, from, null, SENDFILE_MAX)) { - case let err: rt::errno => - switch (err) { - case rt::EINVAL => - if (sum == 0) { - return errors::unsupported; - }; - return errors::errno(err); - case => - return errors::errno(err); - }; - case let n: size => - yield switch (n) { - case 0 => - break; - case => - yield n; - }; + for (true) match (rt::sendfile(to, from, null, SENDFILE_MAX)) { + case let err: rt::errno => + if (err == rt::EINVAL && sum == 0) { + return errors::unsupported; }; + return errors::errno(err); + case let n: size => + if (n == 0) break; sum += n; }; return sum;