Skip to content

Commit 788dd51

Browse files
committed
Fixes
1 parent 8269413 commit 788dd51

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/Utilities/DoubleDicts.jl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ Convert the `value` stored inside `dict` to the equivalent on the outer
1616
`DoubleDict`. This is useful when the value type `V` of the inner dict is
1717
different to the outer dict. (See, e.g., [`IndexDoubleDict`](@ref).)
1818
"""
19-
function typed_value(::AbstractDoubleDictInner{F,S,V}, value::V) where {F,S,V}
20-
return value
21-
end
19+
typed_value(::AbstractDoubleDictInner, value) = value
2220

2321
"""
2422
DoubleDict{V}
@@ -164,10 +162,7 @@ function Base.get(
164162
key::MOI.ConstraintIndex{F,S},
165163
default,
166164
) where {F,S}
167-
if !haskey(d, key)
168-
return default
169-
end
170-
return typed_value(d, d.inner[key.value])
165+
return typed_value(d, get(d.inner, key.value, default))
171166
end
172167

173168
# Base.getindex
@@ -184,10 +179,10 @@ function Base.getindex(
184179
d::AbstractDoubleDictInner{F,S},
185180
key::MOI.ConstraintIndex{F,S},
186181
) where {F,S}
187-
if !haskey(d, key)
182+
x = get(d.inner, key.value) do
188183
throw(KeyError(key))
189184
end
190-
return typed_value(d, d.inner[key.value])
185+
return typed_value(d, x)
191186
end
192187

193188
# Base.setindex!

0 commit comments

Comments
 (0)