Skip to content

Commit

Permalink
Optimize deep_enough_copy for faster notebook updates (#2974)
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp authored Aug 5, 2024
1 parent e0055fc commit 8b7a65d
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 @@ -199,14 +199,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 8b7a65d

Please sign in to comment.