omnia icon indicating copy to clipboard operation
omnia copied to clipboard

Apply the `omnia.repl.context` operations at once

Open AvramRobert opened this issue 4 years ago • 0 comments

The context-altering operations in omnia.repl.context continously extract, patch and re-associate the huds in the context. They basically update constantly for every operation. Whilst this may be transparent, it is also a bit inefficient. (even with the low cost of association)

Begs the question: Is association distributive over these operations? If it is, then we could apply all the changes to the huds at once and then associate the new one. Broken down, this is actually what happens in every function:

(-> ctx  
    (update :hud change-1)
    (update :hud change-2))

Can't we do this?

(let [hud (:hud ctx)]
(->> hud (change-1) (change-2) (assoc ctx :hud)))

AvramRobert avatar Nov 01 '21 22:11 AvramRobert