Skip to content

Commit

Permalink
Optimize deep_enough_copy for faster notebook updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Aug 5, 2024
1 parent 34409a7 commit 45f9ebc
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/webserver/Dynamic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,17 @@ function send_notebook_changes!(πŸ™‹::ClientRequest; commentary::Any=nothing, sk
try_event_call(πŸ™‹.session, FileEditEvent(πŸ™‹.notebook))
end

"Like `deepcopy`, but anything onther than `Dict` gets a shallow (reference) copy."
function deep_enough_copy(d::Dict{A,B}) where {A, B}
Dict{A,B}(
k => deep_enough_copy(v)
for (k, v) in d
)
"Like `deepcopy`, but anything other than `Dict` gets a shallow (reference) copy."
@generated function deep_enough_copy(d::Dict)
quote
out = $d()
for (k,v) in d
out[k] = deep_enough_copy(v)
end
out
end
end
deep_enough_copy(x) = x
deep_enough_copy(d) = d

"""
A placeholder path. The path elements that it replaced will be given to the function as arguments.
Expand Down

0 comments on commit 45f9ebc

Please sign in to comment.