Skip to content

Commit 466acb2

Browse files
committed
Simplify VarNamedVector constructors
1 parent 8b5bd47 commit 466acb2

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

src/varnamedvector.jl

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ struct VarNamedVector{
161161
ranges,
162162
vals::TVal,
163163
transforms::TTrans,
164-
is_unconstrained,
165-
num_inactive,
164+
is_unconstrained=fill!(BitVector(undef, length(varnames)), 0),
165+
num_inactive=OrderedDict{Int,Int}(),
166166
) where {K,V,TVN<:AbstractVector{K},TVal<:AbstractVector{V},TTrans<:AbstractVector}
167167
if length(varnames) != length(ranges) ||
168168
length(varnames) != length(transforms) ||
@@ -237,28 +237,7 @@ struct VarNamedVector{
237237
end
238238
end
239239

240-
# Default values for is_unconstrained (all false) and num_inactive (empty).
241-
function VarNamedVector(
242-
varname_to_index,
243-
varnames,
244-
ranges,
245-
vals,
246-
transforms,
247-
is_unconstrained=fill!(BitVector(undef, length(varnames)), 0),
248-
)
249-
return VarNamedVector(
250-
varname_to_index,
251-
varnames,
252-
ranges,
253-
vals,
254-
transforms,
255-
is_unconstrained,
256-
OrderedDict{Int,Int}(),
257-
)
258-
end
259-
260-
# TODO(mhauru) Are we sure we want the last one to be of type Any[]? Might this cause
261-
# unnecessary type instability?
240+
# TODO(mhauru) Are we sure we want the last one to be of type Any[]?
262241
function VarNamedVector{K,V}() where {K,V}
263242
return VarNamedVector(OrderedDict{K,Int}(), K[], UnitRange{Int}[], V[], Any[])
264243
end

0 commit comments

Comments
 (0)