Skip to content

Commit

Permalink
perf: force a lazy in the branch where it is used
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Dec 4, 2024
1 parent 709d110 commit 7639acf
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,11 @@ let find_map f l =
let header_list_contains_ (s : string) (name : string) : bool =
let name' = String.lowercase_ascii name in
let fragments = String.split_on_char ',' s in
List.exists (fun fragment ->
String.lowercase_ascii (String.trim fragment) = name') fragments
List.exists
(fun fragment -> String.lowercase_ascii (String.trim fragment) = name')
fragments
(* handle client on [ic] and [oc] *)
(** handle client on [ic] and [oc] *)
let client_handle_for (self : t) ~client_addr ic oc : unit =
Pool.with_resource self.bytes_pool @@ fun bytes_req ->
Pool.with_resource self.bytes_pool @@ fun bytes_res ->
Expand Down Expand Up @@ -414,10 +415,10 @@ let client_handle_for (self : t) ~client_addr ic oc : unit =
(* merge per-request middlewares with the server-global middlewares *)
let get_middlewares ~handler_middlewares () : _ list =
let global_middlewares = Lazy.force self.middlewares_sorted in
if handler_middlewares = [] then
if handler_middlewares = [] then (
let global_middlewares = Lazy.force self.middlewares_sorted in
global_middlewares
else
) else
sort_middlewares_ (List.rev_append handler_middlewares self.middlewares)
in
Expand Down

0 comments on commit 7639acf

Please sign in to comment.