Skip to content

Commit d393923

Browse files
committed
get_cset_sv: return as soon as cset is found
1 parent 0afc163 commit d393923

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

src/systems/connectors.jl

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ function generate_connection_equations_and_stream_connections(csets::AbstractVec
309309
vtype = get_connection_type(v)
310310
if vtype === Stream
311311
push!(stream_connections, cset)
312-
continue
313312
elseif vtype === Flow
314313
rhs = 0
315314
for ele in cset.set
@@ -391,8 +390,7 @@ function expand_instream(csets::AbstractVector{<:ConnectionSet}, sys::AbstractSy
391390
end
392391
end
393392
if debug
394-
@info "Expanding at [$idx_in_set]" ex ConnectionSet(cset)
395-
@show n_inners, n_outers
393+
@info "Expanding at [$idx_in_set]" ex ConnectionSet(cset) n_inners n_outers
396394
end
397395
if n_inners == 1 && n_outers == 0
398396
sub[ex] = sv
@@ -511,26 +509,16 @@ function get_cset_sv(namespace, ex, csets)
511509
ns_sv = only(arguments(ex))
512510
full_name_sv = renamespace(namespace, ns_sv)
513511

514-
cidx = -1
515-
idx_in_set = -1
516-
sv = ns_sv
517-
for (i, c) in enumerate(csets)
512+
for c in csets
518513
crep = first(c.set)
519514
current = namespace == crep.sys.namespace
520-
for (j, v) in enumerate(c.set)
515+
for (idx_in_set, v) in enumerate(c.set)
521516
if isequal(namespaced_var(v), full_name_sv) && (current || !v.isouter)
522-
cidx = i
523-
idx_in_set = j
524-
sv = v.v
517+
return c.set, idx_in_set, v.v
525518
end
526519
end
527520
end
528-
cidx < 0 && error("$ns_sv is not a variable inside stream connectors")
529-
cset = csets[cidx].set
530-
#if namespace != first(cset).sys.namespace
531-
# cset = map(c->@set(c.isouter = false), cset)
532-
#end
533-
cset, idx_in_set, sv
521+
error("$ns_sv is not a variable inside stream connectors")
534522
end
535523

536524
# instream runtime

0 commit comments

Comments
 (0)