@@ -13,13 +13,13 @@ function dispatch_op_name(::Val{deg}, ::Nothing, idx)::Vector{Char} where {deg}
13
13
end
14
14
function dispatch_op_name (:: Val{deg} , operators:: AbstractOperatorEnum , idx) where {deg}
15
15
if deg == 1
16
- return get_op_name (operators. unaops[idx]):: Vector{Char}
16
+ return collect ( get_op_name (operators. unaops[idx]):: String )
17
17
else
18
- return get_op_name (operators. binops[idx]):: Vector{Char}
18
+ return collect ( get_op_name (operators. binops[idx]):: String )
19
19
end
20
20
end
21
21
22
- const OP_NAME_CACHE = (; x= Dict {UInt64,Vector{Char} } (), lock= Threads. SpinLock ())
22
+ const OP_NAME_CACHE = (; x= Dict {UInt64,String } (), lock= Threads. SpinLock ())
23
23
24
24
function get_op_name (op)
25
25
h = hash (op)
@@ -29,18 +29,17 @@ function get_op_name(op)
29
29
if haskey (cache, h)
30
30
return cache[h]
31
31
end
32
- op_s = sizehint! (Char[], 10 )
33
- if op isa Broadcast. BroadcastFunction
34
- append! (op_s, string (op. f))
35
- if length (op_s) == 1 && first (op_s) in (' +' , ' -' , ' *' , ' /' , ' ^' )
32
+ op_s = if op isa Broadcast. BroadcastFunction
33
+ base_op_s = string (op. f)
34
+ if length (base_op_s) == 1 && first (base_op_s) in (' +' , ' -' , ' *' , ' /' , ' ^' )
36
35
# Like `.+`
37
- pushfirst! (op_s, ' .' )
36
+ string ( ' .' , base_op_s )
38
37
else
39
38
# Like `cos.`
40
- push! (op_s , ' .' )
39
+ string (base_op_s , ' .' )
41
40
end
42
41
else
43
- append! (op_s, string (op) )
42
+ string (op)
44
43
end
45
44
cache[h] = op_s
46
45
return op_s
0 commit comments