@@ -218,17 +218,11 @@ function direct_links!(cl::CodeLinks, src::CodeInfo)
218218 # Utility for when a stmt itself contains a CodeInfo
219219 function add_inner! (cl:: CodeLinks , icl:: CodeLinks , idx)
220220 for (name, _) in icl. nameassigns
221- assigns = get (cl. nameassigns, name, nothing )
222- if assigns === nothing
223- cl. nameassigns[name] = assigns = Int[]
224- end
221+ assigns = get! (Vector{Int}, cl. nameassigns, name)
225222 push! (assigns, idx)
226223 end
227224 for (name, _) in icl. namesuccs
228- succs = get (cl. namesuccs, name, nothing )
229- if succs === nothing
230- cl. namesuccs[name] = succs = Links ()
231- end
225+ succs = get! (Links, cl. namesuccs, name)
232226 push! (succs. ssas, idx)
233227 end
234228 end
@@ -255,10 +249,7 @@ function direct_links!(cl::CodeLinks, src::CodeInfo)
255249 cl. nameassigns[name] = assign = Int[]
256250 end
257251 push! (assign, i)
258- targetstore = get (cl. namepreds, name, nothing )
259- if targetstore === nothing
260- cl. namepreds[name] = targetstore = Links ()
261- end
252+ targetstore = get! (Links, cl. namepreds, name)
262253 target = P (name, targetstore)
263254 add_links! (target, stmt, cl)
264255 elseif name in (nothing , false )
@@ -281,10 +272,7 @@ function direct_links!(cl::CodeLinks, src::CodeInfo)
281272 if isa (lhs, Symbol)
282273 lhs = GlobalRef (cl. thismod, lhs)
283274 end
284- targetstore = get (cl. namepreds, lhs, nothing )
285- if targetstore === nothing
286- cl. namepreds[lhs] = targetstore = Links ()
287- end
275+ targetstore = get! (Links, cl. namepreds, lhs)
288276 target = P (lhs, targetstore)
289277 assign = get (cl. nameassigns, lhs, nothing )
290278 if assign === nothing
@@ -320,20 +308,14 @@ function add_links!(target::Pair{Union{SSAValue,SlotNumber,GlobalRef},Links}, @n
320308 stmt = GlobalRef (cl. thismod, stmt)
321309 end
322310 push! (targetstore, stmt)
323- namestore = get (cl. namesuccs, stmt, nothing )
324- if namestore === nothing
325- cl. namesuccs[stmt] = namestore = Links ()
326- end
311+ namestore = get! (Links, cl. namesuccs, stmt)
327312 push! (namestore, targetid)
328313 elseif isa (stmt, Expr)
329314 if stmt. head === :globaldecl
330315 for i = 1 : length (stmt. args)
331316 a = stmt. args[i]
332317 if a isa GlobalRef
333- namestore = get (cl. namepreds, a, nothing )
334- if namestore === nothing
335- cl. namepreds[a] = namestore = Links ()
336- end
318+ namestore = get! (Links, cl. namepreds, a)
337319 push! (namestore, targetid)
338320 if targetid isa SSAValue
339321 push! (namestore, SSAValue (targetid. id+ 1 )) # +1 for :latestworld
@@ -1101,7 +1083,7 @@ function print_with_code(io::IO, src::CodeInfo, isrequired::AbstractVector{Bool}
11011083 preprint (:: IO ) = nothing
11021084 preprint (io:: IO , idx:: Int ) = (c = isrequired[idx]; printstyled (io, lpad (idx, nd), ' ' , c ? " t " : " f " ; color = c ? :cyan : :plain ))
11031085 postprint (:: IO ) = nothing
1104- postprint (io :: IO , idx:: Int , bbchanged:: Bool ) = nothing
1086+ postprint (:: IO , idx:: Int , bbchanged:: Bool ) = nothing
11051087
11061088 print_with_code (preprint, postprint, io, src)
11071089end
0 commit comments