Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/unix/lwt_unix.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ let recv ch buf pos len flags =
if pos < 0 || len < 0 || pos > Bytes.length buf - len then
invalid_arg "Lwt_unix.recv"
else
let do_recv = if Sys.win32 then Unix.recv else stub_recv in
let do_recv fd buf pos len fl = if Sys.win32 then Unix.recv fd buf pos len fl else stub_recv fd buf pos len fl in
wrap_syscall Read ch (fun () -> do_recv ch.fd buf pos len flags)
Comment on lines +1552 to 1553
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we're eta-expanding i think we should also inline, very little point in defining the intermediary identifier

    wrap_syscall Read ch (fun () -> if Sys.win32 then Unix.recv ch.fd buf pos len flags else stub_recv ch.fd buf pos len flags)

or maybe even better

else if Sys.win32 then
  wrap_syscall Read ch (fun () -> Unix.recv ch.fd buf pos len flags)
else
  wrap_syscall Read ch (fun () -> stubs_recv ch.fd buf pos len flags)

because it becomes very readable, easy to scan the two lines and spot the difference


external stub_send : Unix.file_descr -> Bytes.t -> int -> int -> Unix.msg_flag list -> int = "lwt_unix_send"
Expand All @@ -1558,7 +1558,7 @@ let send ch buf pos len flags =
if pos < 0 || len < 0 || pos > Bytes.length buf - len then
invalid_arg "Lwt_unix.send"
else
let do_send = if Sys.win32 then Unix.send else stub_send in
let do_send fd buf pos len fl = if Sys.win32 then Unix.send fd buf pos len fl else stub_send fd buf pos len fl in
wrap_syscall Write ch (fun () -> do_send ch.fd buf pos len flags)

external stub_recvfrom : Unix.file_descr -> Bytes.t -> int -> int -> Unix.msg_flag list -> int * Unix.sockaddr = "lwt_unix_recvfrom"
Expand All @@ -1567,7 +1567,7 @@ let recvfrom ch buf pos len flags =
if pos < 0 || len < 0 || pos > Bytes.length buf - len then
invalid_arg "Lwt_unix.recvfrom"
else
let do_recvfrom = if Sys.win32 then Unix.recvfrom else stub_recvfrom in
let do_recvfrom fd buf pos len fl = if Sys.win32 then Unix.recvfrom fd buf pos len fl else stub_recvfrom fd buf pos len fl in
wrap_syscall Read ch (fun () -> do_recvfrom ch.fd buf pos len flags)

external stub_sendto : Unix.file_descr -> Bytes.t -> int -> int -> Unix.msg_flag list -> Unix.sockaddr -> int = "lwt_unix_sendto_byte" "lwt_unix_sendto"
Expand All @@ -1576,7 +1576,7 @@ let sendto ch buf pos len flags addr =
if pos < 0 || len < 0 || pos > Bytes.length buf - len then
invalid_arg "Lwt_unix.sendto"
else
let do_sendto = if Sys.win32 then Unix.sendto else stub_sendto in
let do_sendto fd buf pos len fl a = if Sys.win32 then Unix.sendto fd buf pos len fl a else stub_sendto fd buf pos len fl a in
wrap_syscall Write ch (fun () -> do_sendto ch.fd buf pos len flags addr)

external stub_recv_msg :
Expand Down
Loading