From 6d94a87906675510f99d54d4b5ab3cc06ca924fa Mon Sep 17 00:00:00 2001 From: chethega Date: Wed, 21 Nov 2018 20:27:20 +0100 Subject: [PATCH 1/3] avoid jl_arrayunset in dicts with bitstypes; add some more @inbounds --- base/dict.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/base/dict.jl b/base/dict.jl index 41b36eb5f65fc..44d8dfbb8efb1 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -571,7 +571,7 @@ function getkey(h::Dict{K,V}, key, default) where V where K end function _pop!(h::Dict, index) - val = h.vals[index] + @inbounds val = h.vals[index] _delete!(h, index) return val end @@ -619,10 +619,10 @@ function pop!(h::Dict) key => val end -function _delete!(h::Dict, index) - h.slots[index] = 0x2 - ccall(:jl_arrayunset, Cvoid, (Any, UInt), h.keys, index-1) - ccall(:jl_arrayunset, Cvoid, (Any, UInt), h.vals, index-1) +function _delete!(h::Dict{K,V}, index) where {K,V} + @inbounds h.slots[index] = 0x2 + isbitstype(K) || ccall(:jl_arrayunset, Cvoid, (Any, UInt), h.keys, index-1) + isbitstype(V) || ccall(:jl_arrayunset, Cvoid, (Any, UInt), h.vals, index-1) h.ndel += 1 h.count -= 1 h.age += 1 From 72fdb2991309cb1956130f8bb728e8aef9f75af9 Mon Sep 17 00:00:00 2001 From: chethega Date: Wed, 21 Nov 2018 22:42:36 +0100 Subject: [PATCH 2/3] also skip jl_arrayunset for isbitsunion --- base/dict.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/dict.jl b/base/dict.jl index 44d8dfbb8efb1..0c30d3eabadab 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -621,8 +621,8 @@ end function _delete!(h::Dict{K,V}, index) where {K,V} @inbounds h.slots[index] = 0x2 - isbitstype(K) || ccall(:jl_arrayunset, Cvoid, (Any, UInt), h.keys, index-1) - isbitstype(V) || ccall(:jl_arrayunset, Cvoid, (Any, UInt), h.vals, index-1) + isbitstype(K) || || isbitsunion(K) || ccall(:jl_arrayunset, Cvoid, (Any, UInt), h.keys, index-1) + isbitstype(V) || isbitsunion(V) || ccall(:jl_arrayunset, Cvoid, (Any, UInt), h.vals, index-1) h.ndel += 1 h.count -= 1 h.age += 1 From d7198bf0daa83d505ee2814251e3b0db56ef73e4 Mon Sep 17 00:00:00 2001 From: chethega Date: Thu, 22 Nov 2018 01:25:41 +0100 Subject: [PATCH 3/3] amend typo --- base/dict.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/dict.jl b/base/dict.jl index 0c30d3eabadab..3f52110e8b8f9 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -621,7 +621,7 @@ end function _delete!(h::Dict{K,V}, index) where {K,V} @inbounds h.slots[index] = 0x2 - isbitstype(K) || || isbitsunion(K) || ccall(:jl_arrayunset, Cvoid, (Any, UInt), h.keys, index-1) + isbitstype(K) || isbitsunion(K) || ccall(:jl_arrayunset, Cvoid, (Any, UInt), h.keys, index-1) isbitstype(V) || isbitsunion(V) || ccall(:jl_arrayunset, Cvoid, (Any, UInt), h.vals, index-1) h.ndel += 1 h.count -= 1