Skip to content

Commit bd985ba

Browse files
authored
[janitor] Replace listLength == 0 by listEmpty (#12884)
1 parent 131cb1a commit bd985ba

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

OMCompiler/Compiler/BackEnd/SynchronousFeatures.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ algorithm
133133
if not listEmpty(systs) then
134134
BackendDAE.DAE({syst}, shared) := BackendDAEOptimize.collapseIndependentBlocks(BackendDAE.DAE(systs, shared));
135135
(systs, clockedSysts1, unpartRemEqs) := baseClockPartitioning(syst, shared);
136-
assert(listLength(clockedSysts1) == 0, "Get clocked system in SynchronousFeatures.addContVarsEqs");
136+
assert(listEmpty(clockedSysts1), "Get clocked system in SynchronousFeatures.addContVarsEqs");
137137
shared.removedEqs := BackendEquation.addList(unpartRemEqs, shared.removedEqs);
138138
end if;
139139

OMCompiler/Compiler/FrontEnd/StateMachineFlatten.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ algorithm
194194
(transitionLst, otherLst2) := List.extractOnTrue(otherLst1, isTransition);
195195
({initialStateOp}, otherLst3) := List.extractOnTrue(otherLst2, isInitialState);
196196
(eqnLst, otherLst4) := List.extractOnTrue(otherLst3, isEquation);
197-
assert(listLength(otherLst4) == 0, "Internal compiler error. Unexpected elements in flat state machine.");
197+
assert(listEmpty(otherLst4), "Internal compiler error. Unexpected elements in flat state machine.");
198198

199199
DAE.NORETCALL(exp=DAE.CALL(path=Absyn.IDENT("initialState"), expLst={DAE.CREF(componentRef=crefInitialState)})) := initialStateOp;
200200
({initialStateComp}, smCompsLst2) := List.extract1OnTrue(smCompsLst, sMCompEqualsRef, crefInitialState);

OMCompiler/Compiler/NBackEnd/Classes/NBEquation.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2881,7 +2881,7 @@ public
28812881
case SOME(b as WHEN_EQUATION_BODY(condition = condition as Expression.ARRAY())) algorithm
28822882
b.else_when := simplify(b.else_when);
28832883
conditions := list(elem for elem guard(not Expression.isFalse(elem)) in arrayList(condition.elements));
2884-
if listLength(conditions) == 0 then
2884+
if listEmpty(conditions) then
28852885
body := b.else_when;
28862886
elseif listLength(conditions) == 1 then
28872887
b.condition := listHead(conditions);

OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBResolveSingularities.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public
220220
// --------------------------------------------------------
221221
// for both static and dynamic state selection all matched states are regarded dummys
222222
for dummy in dummy_states loop
223-
if listLength(dummy.indices) == 0 then
223+
if listEmpty(dummy.indices) then
224224
dummy_derivatives := BVariable.makeDummyState(Slice.getT(dummy)) :: dummy_derivatives;
225225
else
226226
Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed because slicing during index reduction is not yet supported.\n"

OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBAlias.mo

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -857,11 +857,11 @@ protected
857857
Real max_val;
858858
algorithm
859859
(constants, rest) := List.splitOnTrue(lst_values, Expression.isConstNumber);
860-
if listLength(constants) <> 0 then
860+
if not listEmpty(constants) then
861861
max_val := List.maxElement(list(Expression.realValue(val) for val in constants), realLt);
862862
rest := Expression.REAL(max_val) :: rest;
863863
end if;
864-
if listLength(rest) == 0 then // constants and rest are empty
864+
if listEmpty(rest) then // constants and rest are empty
865865
max_exp := NONE();
866866
elseif listLength(rest) == 1 then // one constant or one rest
867867
max_exp := SOME(List.first(rest));
@@ -886,11 +886,11 @@ protected
886886
Real min_val;
887887
algorithm
888888
(constants, rest) := List.splitOnTrue(lst_values, Expression.isConstNumber);
889-
if listLength(constants) <> 0 then
889+
if not listEmpty(constants) then
890890
min_val := List.minElement(list(Expression.realValue(val) for val in constants), realLt);
891891
rest := Expression.REAL(min_val) :: rest;
892892
end if;
893-
if listLength(rest) == 0 then // constants and rest are empty
893+
if listEmpty(rest) then // constants and rest are empty
894894
min_exp := NONE();
895895
elseif listLength(rest) == 1 then // one constant or one rest
896896
min_exp := SOME(List.first(rest));
@@ -1099,7 +1099,7 @@ protected
10991099
StateSelect sval, state_select = StateSelect.NEVER;
11001100
ComponentRef compref, cref;
11011101
algorithm
1102-
if listLength(lst_values) == 0 then
1102+
if listEmpty(lst_values) then
11031103
chosen_val := NONE();
11041104
chosen_cref := NONE();
11051105
elseif listLength(lst_values) == 1 then
@@ -1127,7 +1127,7 @@ protected
11271127
list<TearingSelect> lst_values = UnorderedMap.valueList(map);
11281128
TearingSelect tearing_select;
11291129
algorithm
1130-
if listLength(lst_values) == 0 then
1130+
if listEmpty(lst_values) then
11311131
chosen_val := NONE();
11321132
elseif listLength(lst_values) == 1 then
11331133
chosen_val := SOME(List.first(lst_values));

OMCompiler/Compiler/NBackEnd/Modules/3_Post/NBSolve.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ protected
789789
(var_cref, solve_status) := getVarSlice(BVariable.getVarName(Util.getOption(record_parent)), eqn);
790790
else
791791
// todo: choose best slice of list if more than one.
792-
// only fail for listLength == 0
792+
// only fail for listEmpty
793793
solve_status := Status.UNSOLVABLE;
794794
end if;
795795
end if;

0 commit comments

Comments
 (0)