Skip to content

Commit e9c4e9f

Browse files
ll-arall-ara
and
ll-ara
authored
Up to 7x faster _save_outputs!() (#1217)
* used mapping to improve _save_outputs performance * fixed line that was too long * reinstated _output_value_by_ind and changed ‘collect’ to ‘Dict’ --------- Co-authored-by: ll-ara <ll-ara@no-reply.com>
1 parent c5b821a commit e9c4e9f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/run_spineopt_basic.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -995,13 +995,12 @@ function _do_save_outputs!(m, output_names, output_suffix; weight=1)
995995
end
996996
by_suffix = get!(m.ext[:spineopt].outputs, out_name, Dict())
997997
by_window = get!(by_suffix, output_suffix, Dict())
998-
by_window[w_start, w_end] = Dict(
999-
_static(ind) => weight * val for (ind, val) in _output_value_by_ind(m, something(value, param))
1000-
)
998+
by_window[w_start, w_end] = Dict(Iterators.map(((ind, val),) ->
999+
(_static(ind), weight * val), _output_value_by_ind(m, something(value, param))))
10011000
end
10021001
end
10031002

1004-
_static(ind::NamedTuple) = (; (k => _static(v) for (k, v) in pairs(ind))...)
1003+
_static(ind::NamedTuple) = NamedTuple{keys(ind)}(map(_static, values(ind)))
10051004
_static(t::TimeSlice) = (start(t), end_(t))
10061005
_static(x) = x
10071006

0 commit comments

Comments
 (0)