Skip to content

Commit e995fc3

Browse files
committed
Allow faster merge for Dicts
1 parent e1def10 commit e995fc3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

base/associative.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ Dict{String,Float64} with 3 entries:
254254
```
255255
"""
256256
merge(d::Associative, others::Associative...) =
257-
merge!(emptymergedict(d, others...), d, others...)
257+
merge!(_typeddict(d, others...), others...)
258258

259259
"""
260260
merge(combine, d::Associative, others::Associative...)
@@ -283,16 +283,16 @@ Dict{String,Float64} with 3 entries:
283283
```
284284
"""
285285
merge(combine::Function, d::Associative, others::Associative...) =
286-
merge!(combine, emptymergedict(d, others...), d, others...)
286+
merge!(combine, _typeddict(d, others...), others...)
287287

288288
promoteK(K) = K
289289
promoteV(V) = V
290290
promoteK(K, d, ds...) = promoteK(promote_type(K, keytype(d)), ds...)
291291
promoteV(V, d, ds...) = promoteV(promote_type(V, valtype(d)), ds...)
292-
function emptymergedict(d::Associative, others::Associative...)
292+
function _typeddict(d::Associative, others::Associative...)
293293
K = promoteK(keytype(d), others...)
294294
V = promoteV(valtype(d), others...)
295-
Dict{K,V}()
295+
Dict{K,V}(d)
296296
end
297297

298298
"""

0 commit comments

Comments
 (0)