mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 03:05:31 -05:00
perf: small changes in Event
This commit is contained in:
parent
1eb26e5091
commit
9c57dad3f1
1 changed files with 14 additions and 7 deletions
|
|
@ -6,14 +6,21 @@ let nop_handler_ _ = assert false
|
|||
module Emitter = struct
|
||||
type nonrec ('a, 'b) t = ('a, 'b) t
|
||||
|
||||
let emit (self : (_, unit) t) x = Vec.iter self.h ~f:(fun h -> h x)
|
||||
let emit (self : (_, unit) t) x =
|
||||
if not (Vec.is_empty self.h) then
|
||||
(Vec.iter [@inlined]) self.h ~f:(fun h -> h x)
|
||||
|
||||
let emit_collect (self : _ t) x : _ list =
|
||||
if Vec.is_empty self.h then
|
||||
[]
|
||||
else (
|
||||
let l = ref [] in
|
||||
Vec.iter self.h ~f:(fun h -> l := h x :: !l);
|
||||
!l
|
||||
)
|
||||
|
||||
let emit_iter self x ~f =
|
||||
if not (Vec.is_empty self.h) then
|
||||
Vec.iter self.h ~f:(fun h ->
|
||||
let y = h x in
|
||||
f y)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue