Skip to content

Commit dc242e4

Browse files
authored
favour builtin over List functions (OpenModelica#13722)
1 parent 7938dbb commit dc242e4

17 files changed

+72
-76
lines changed

OMCompiler/Compiler/BackEnd/BackendDAECreate.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ algorithm
469469
case 1 then DAE.ARRAY(ComponentReference.crefTypeFull(cref), true, expLst);
470470
case 2 algorithm
471471
dims := Types.getDimensions(ComponentReference.crefLastType(cref));
472-
firstDim := match List.first(dims)
472+
firstDim := match listHead(dims)
473473
case DAE.DIM_INTEGER(firstDim) then firstDim;
474474
end match;
475475
try

OMCompiler/Compiler/BackEnd/DataReconciliation.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,7 +2365,7 @@ algorithm
23652365
for blocks in predecessorBlockInfo loop
23662366
(mainBlock, targetBlocks, _, knownBlocks, constantBlocks, _) := blocks;
23672367
if not listEmpty(knownBlocks) then // known Blocks
2368-
targetBlocksWithKnowns := filterTargetBlocksWithoutRanks(List.rest(targetBlocks), targetBlocksWithKnowns);
2368+
targetBlocksWithKnowns := filterTargetBlocksWithoutRanks(listRest(targetBlocks), targetBlocksWithKnowns);
23692369
elseif not listEmpty(constantBlocks) then // constant Blocks
23702370
targetBlocksWithConstants := filterTargetBlocksWithoutRanks(targetBlocks, targetBlocksWithConstants);
23712371
else // unknown Blocks
@@ -3090,7 +3090,7 @@ algorithm
30903090
for tmpblocks in blockinfo loop
30913091
(_, tmptargetblocks, _) := tmpblocks;
30923092
if not intEq(count,tmpcount) then
3093-
if listMember(List.first(targetblocks), tmptargetblocks) then
3093+
if listMember(listHead(targetblocks), tmptargetblocks) then
30943094
targetexist := true;
30953095
end if;
30963096
end if;

OMCompiler/Compiler/BackEnd/HpcOmMemory.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2517,7 +2517,7 @@ import Util;
25172517
if(boolNot(listEmpty(iVarList))) then
25182518
varHead = listHead(iVarList);
25192519
if(intEq(varHead, varIdx)) then
2520-
iVarList = List.rest(iVarList);
2520+
iVarList = listRest(iVarList);
25212521
//print("createMemoryMapTraverse0: Removed variable " + intString(varIdx) + "\n");
25222522
end if;
25232523
end if;

OMCompiler/Compiler/BackEnd/HpcOmScheduler.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5532,8 +5532,8 @@ protected
55325532
array<Real> tdsLevel = tdsLevelIn;
55335533
algorithm
55345534
while not(listEmpty(nodes)) loop
5535-
if arrayGet(visitedNodes, List.first(nodes)) then
5536-
nodes := List.rest(nodes);
5535+
if arrayGet(visitedNodes, listHead(nodes)) then
5536+
nodes := listRest(nodes);
55375537
else
55385538
nodes := computeGraphValuesTopDown2(nodes,iTaskGraph,iTaskGraphT,iTaskGraphMeta,alap,last,lact,tdsLevel,visitedNodes);
55395539
end if;

OMCompiler/Compiler/BackEnd/ResolveLoops.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,9 +1338,9 @@ algorithm
13381338
eqs := List.unique(eqs);
13391339
eqs := List.intersectionOnTrue(eqs,loopIn,intEq);
13401340
if listEmpty(eqs) then
1341-
next := List.first(loopIn);
1341+
next := listHead(loopIn);
13421342
else
1343-
next := List.first(eqs);
1343+
next := listHead(eqs);
13441344
end if;
13451345
rest := List.deleteMemberOnTrue(next,loopIn,intEq);
13461346
then sortLoop(rest,m,mT,next::sortLoopIn);

OMCompiler/Compiler/BackEnd/SymbolicJacobian.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,7 @@ protected
26462646
BackendDAE.EqSystem syst;
26472647
algorithm
26482648
(BackendDAE.DAE(systems, shared), _, _, _, _, _) := jacobian;
2649-
syst := List.first(systems); // Only the first system contains directional derivative,
2649+
syst := listHead(systems); // Only the first system contains directional derivative,
26502650
// the others contain optional constant equations
26512651
dependencies := BackendEquation.getCrefsFromEquations(syst.orderedEqs, syst.orderedVars, shared.globalKnownVars);
26522652
end calcJacobianDependencies;

OMCompiler/Compiler/BackEnd/SynchronousFeatures.mo

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,13 +1799,13 @@ protected
17991799
Integer i;
18001800
DAE.Exp e, subclk;
18011801
algorithm
1802-
DAE.CREF(componentRef = cr) := List.first(inExpLst);
1802+
DAE.CREF(componentRef = cr) := listHead(inExpLst);
18031803
(_, varIxs) := BackendVariable.getVar(cr, inVars);
1804-
i := List.first(varIxs);
1805-
i := List.first(arrayGet(mT, i)) "Equation idx, containing var";
1804+
i := listHead(varIxs);
1805+
i := listHead(arrayGet(mT, i)) "Equation idx, containing var";
18061806
i := arrayGet(inPartitions, i) "Partitions, from which var get";
18071807
subclk := DAE.CREF(getSubClkName(i, 1), DAE.T_CLOCK_DEFAULT);
1808-
e := DAE.CALL(inPath, subclk::List.rest(inExpLst), inAttr);
1808+
e := DAE.CALL(inPath, subclk::listRest(inExpLst), inAttr);
18091809
(outVar, outEq) := createSubClock(inPartitionIdx, inClkCnt, e);
18101810
end createSubClockVar;
18111811

@@ -1972,7 +1972,7 @@ protected function createSubClockVarFactor
19721972
protected
19731973
DAE.Exp e;
19741974
algorithm
1975-
outExp := substGetPartition(List.first(inExpLst));
1975+
outExp := substGetPartition(listHead(inExpLst));
19761976
//To do this, the eqPartMap has to exclude the subPartition interfaces. Anyway, its not used anymore
19771977
/*
19781978
(outExp, outNewEqs, outNewVars, outClkCnt) := match listGet(inExpLst, 2)
@@ -2415,7 +2415,7 @@ protected
24152415
Boolean create;
24162416
DAE.Exp e;
24172417
algorithm
2418-
e := List.first(inExps);
2418+
e := listHead(inExps);
24192419
create := match e
24202420
case DAE.CREF() then false;
24212421
case DAE.RCONST() then false;
@@ -2436,7 +2436,7 @@ algorithm
24362436
ty := Expression.typeof(e);
24372437
cr := DAE.CREF_IDENT("$var" + intString(inCnt), ty, {});
24382438
(var, eq) := createEqVarPair(cr, ty, e);
2439-
then (DAE.CREF(cr, ty)::List.rest(inExps), eq::inEqs, var::inVars, inCnt + 1);
2439+
then (DAE.CREF(cr, ty)::listRest(inExps), eq::inEqs, var::inVars, inCnt + 1);
24402440
case false
24412441
then (inExps, inEqs, inVars, inCnt);
24422442
end match;

OMCompiler/Compiler/BackEnd/Uncertainties.mo

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,8 +1184,8 @@ algorithm
11841184
(_,tmptargetblocks,_):= tmpblocks;
11851185
if(not intEq(count,tmpcount)) then
11861186
//print("Targets:" + intString(tmpcount) + ": " + anyString(tmptargetblocks) + "\n ");
1187-
//print("first block:" + anyString(List.first(targetblocks))+ "\n");
1188-
if(listMember(List.first(targetblocks),tmptargetblocks)) then
1187+
//print("first block:" + anyString(listHead(targetblocks))+ "\n");
1188+
if(listMember(listHead(targetblocks),tmptargetblocks)) then
11891189
//print("Predeccsors Block Found:" + anyString(targetblocks) + "\n");
11901190
targetexist:=true;
11911191
end if;
@@ -1285,7 +1285,7 @@ algorithm
12851285
for blocks in blockinfo loop
12861286
(blockitems1,targetblocks,targetblocksvar):= blocks;
12871287
(blockstoupdate,exist,foundblock):=findSquareAndNonSquareBlocksHelper(targetblocks,targetblocksvar);
1288-
(blockvarlst1,_):=List.first(targetblocksvar);
1288+
(blockvarlst1,_):=listHead(targetblocksvar);
12891289
outlist1:=(blockitems1,blockvarlst1,exist,foundblock)::outlist1;
12901290
for j in blockstoupdate loop
12911291
(blockitem,_):=j;
@@ -1428,12 +1428,12 @@ algorithm
14281428
print("\nLoop-1\n"+ "========\n");
14291429
for blocks in predecessortargetinfo loop
14301430
(blockitems,targetblocks,targetblocksvar,knownblocks,foundblockranks):= blocks;
1431-
(dependendblock,_):=listGet(allblockranks,List.first(foundblockranks));
1431+
(dependendblock,_):=listGet(allblockranks,listHead(foundblockranks));
14321432
targetblocktobeinserted:=List.setDifferenceOnTrue(knownblocks,usedblocks,intEq);
14331433
print("\nExtractEquationsfromNoPredecessorBlocks :" + dumplistInteger(blockitems) + " => " + dumplistInteger(dependendblock) + " => known blocks:" + dumplistInteger(targetblocktobeinserted) + "\n");
14341434
//print("\ntargetblocktobeinserted :" + anyString(targetblocktobeinserted) + "=> SET_S :" + anyString(usedblocks));
14351435
if(not listEmpty(targetblocktobeinserted)) then
1436-
usedblocks:=List.first(targetblocktobeinserted)::usedblocks;
1436+
usedblocks:=listHead(targetblocktobeinserted)::usedblocks;
14371437
else
14381438
//print("\n Problem is ill posed because there are two few variables of interest. Boundary condition A is ignored \n");
14391439
blockspostoberemoved:=tmpcount::blockspostoberemoved;
@@ -1451,8 +1451,8 @@ algorithm
14511451
blocksize:=listLength(blockitems)-1;
14521452
sets:=listAppend(List.firstN(blockitems,blocksize),sets);
14531453
// insert 1 equation of targetBlock into set-s
1454-
//sets:=List.first(dependendblock)::sets;
1455-
sets:=List.first(targetblocktobeinserted)::sets;
1454+
//sets:=listHead(dependendblock)::sets;
1455+
sets:=listHead(targetblocktobeinserted)::sets;
14561456
print("\nAfterinsertion :" + dumplistInteger(targetblocktobeinserted) + "=> SET_S :" + dumplistInteger(sets) + "\n");
14571457
elseif(not List.setEqualOnTrue(blockitems,dependendblock,intEq) and listEmpty(targetblocktobeinserted)) then
14581458
// Block does not exist

OMCompiler/Compiler/FrontEnd/ConnectUtil.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2518,7 +2518,7 @@ algorithm
25182518
inside := removeStreamSetElement(streamCref, inside);
25192519
e := streamSumEquationExp(outside, inside, flowThreshold);
25202520
if not listEmpty(inside) then
2521-
expr := streamFlowExp(List.first(inside));
2521+
expr := streamFlowExp(listHead(inside));
25222522
e := Expression.makePureBuiltinCall("$OMC$inStreamDiv", {e, expr}, Expression.typeof(e));
25232523
end if;
25242524
// Evaluate any inStream calls that were generated.

OMCompiler/Compiler/FrontEnd/Expression.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3483,7 +3483,7 @@ public function makeTuple
34833483
input list<DAE.Exp> inExps;
34843484
output DAE.Exp outExp;
34853485
algorithm
3486-
outExp := if listLength(inExps) > 1 then DAE.TUPLE(inExps) else List.first(inExps);
3486+
outExp := if listLength(inExps) > 1 then DAE.TUPLE(inExps) else listHead(inExps);
34873487
end makeTuple;
34883488

34893489

0 commit comments

Comments
 (0)