Skip to content

Commit

Permalink
Avoid allocation in no-op update
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Dec 10, 2023
1 parent e2ba10a commit 59b04b1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/kcas/kcas.ml
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,10 @@ module Xt = struct
end
else
let current = state_r.after in
let state = State { state_r with after = f current } in
let after = f current in
let state =
if current == after then state else State { state_r with after }
in
xt.cass <- Cas { loc; state; lt; gt; awaiters = [] };
current

Expand Down

0 comments on commit 59b04b1

Please sign in to comment.