Avoiding double lookup

You can use Base.ht_keyindex like get does internally:

function get(h::Dict{K,V}, key, default) where V where K
    index = ht_keyindex(h, key)
    @inbounds return (index < 0) ? default : h.vals[index]::V
end

In your case, if index < 0 you would set d[k] = 1