mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-05 19:00:32 -05:00
feat(headers): set will not reallocate whole list if not needed
This commit is contained in:
parent
cdac33689a
commit
d7a5cca1d4
1 changed files with 9 additions and 1 deletions
|
|
@ -35,7 +35,15 @@ let get ?(f = fun x -> x) x h =
|
|||
try Some (get_exn ~f x h) with Not_found -> None
|
||||
|
||||
let remove x h = List.filter (fun (k, _) -> not (equal_name_ k x)) h
|
||||
let set x y h = (x, y) :: List.filter (fun (k, _) -> not (equal_name_ k x)) h
|
||||
|
||||
let set x y h =
|
||||
let h =
|
||||
if contains x h then
|
||||
remove x h
|
||||
else
|
||||
h
|
||||
in
|
||||
(x, y) :: h
|
||||
|
||||
let pp out l =
|
||||
let pp_pair out (k, v) = Format.fprintf out "@[<h>%s: %s@]" k v in
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue