Skip to content

Commit fe59e20

Browse files
committed
final suggestions applied
1 parent 4e83bac commit fe59e20

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/ordered_robin_dict.jl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function _setindex!(h::OrderedRobinDict, v, key)
122122
end
123123

124124
function setindex!(h::OrderedRobinDict{K, V}, v0, key0) where {K,V}
125-
key = convert(K,key0)
125+
key = convert(K, key0)
126126
v = convert(V, v0)
127127
index = get(h.dict, key, -2)
128128

@@ -150,22 +150,18 @@ end
150150
function rehash!(h::OrderedRobinDict{K, V}) where {K, V}
151151
keys = h.keys
152152
vals = h.vals
153-
newk = Vector{K}()
154-
newv = Vector{V}()
155-
hk, hv = newk, newv
153+
hk = Vector{K}()
154+
hv = Vector{V}()
156155

157156
for (idx, (k, v)) in enumerate(zip(keys, vals))
158157
if get(h.dict, k, -1) == idx
159-
ccall(:jl_array_grow_end, Cvoid, (Any, UInt), hk, 1)
160-
nk = length(hk)
161-
@inbounds hk[nk] = k
162-
ccall(:jl_array_grow_end, Cvoid, (Any, UInt), hv, 1)
163-
@inbounds hv[nk] = v
158+
push!(hk, k)
159+
push!(hv, v)
164160
end
165161
end
166162

167-
h.keys = newk
168-
h.vals = newv
163+
h.keys = hk
164+
h.vals = hv
169165

170166
for (idx, k) in enumerate(h.keys)
171167
h.dict[k] = idx

0 commit comments

Comments
 (0)