Skip to content

Commit

Permalink
Call Bigstringaf.copy instead of copying after
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro committed Aug 5, 2022
1 parent 3435604 commit 090a03f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions mirage/gluten_mirage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,13 @@ module Make_IO (Flow : Mirage_flow.S) :
let cstruct_iovecs =
List.map
(fun { Faraday.buffer; off; len } ->
Cstruct.of_bigarray ~off ~len buffer)
let copy = Bigstringaf.copy ~off ~len buffer in
Cstruct.of_bigarray ~off:0 ~len copy)
iovecs
in
let len = Cstruct.lenv cstruct_iovecs in
let data = Cstruct.create_unsafe len in
let _, _ = Cstruct.fillv ~src:cstruct_iovecs ~dst:data in
Lwt.catch
(fun () ->
Flow.write sock.flow data >|= fun x ->
Flow.writev sock.flow cstruct_iovecs >|= fun x ->
match x with
| Ok () ->
`Ok (Cstruct.lenv cstruct_iovecs)
Expand Down

1 comment on commit 090a03f

@ansiwen
Copy link
Contributor

@ansiwen ansiwen commented on 090a03f Aug 5, 2022

Choose a reason for hiding this comment

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

I don't think that is efficient. See #32 (comment)

Please sign in to comment.