Skip to content

Commit dd8d3c7

Browse files
Improve getdict performance (#42057)
Co-authored-by: Ian Butterworth <i.r.butterworth@gmail.com>
1 parent 49e3aec commit dd8d3c7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

stdlib/Profile/src/Profile.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,14 @@ function retrieve()
214214
end
215215

216216
function getdict(data::Vector{UInt})
217-
# Lookup is expensive, so do it only once per ip.
218-
udata = unique(data)
219217
dict = LineInfoDict()
220-
for ip in udata
218+
return getdict!(dict, data)
219+
end
220+
221+
function getdict!(dict::LineInfoDict, data::Vector{UInt})
222+
for ip in data
223+
# Lookup is expensive, so do it only once per ip.
224+
haskey(dict, UInt64(ip)) && continue
221225
st = lookup(convert(Ptr{Cvoid}, ip))
222226
# To correct line numbers for moving code, put it in the form expected by
223227
# Base.update_stackframes_callback[]

0 commit comments

Comments
 (0)