Skip to content

Commit

Permalink
Use isPresent() to disable some allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Mar 4, 2016
1 parent bcd948c commit a391fa9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions Compiler/FrontEnd/MetaModelicaBuiltin.mo
Expand Up @@ -858,10 +858,12 @@ function referenceDebugString<A>
</html>"));
end referenceDebugString;

impure function isPresent
input OpenModelica.$Code.TypeName ident;
output Boolean b=true;
annotation(Documentation(info="<html>
function isPresent<T>
input T ident;
output Boolean b;
algorithm
b:=true;
annotation(__OpenModelica_EarlyInline=true, __OpenModelica_BuiltinPtr = true, Documentation(info="<html>
<p>From Modelica 2.x:</p>
<p>Returns true if the formal <strike>input or</strike> output argument <i>ident</i>
is present as an actual argument of the function call. If the argument is not
Expand Down
8 changes: 4 additions & 4 deletions Compiler/Util/List.mo
Expand Up @@ -1346,7 +1346,7 @@ algorithm

if b then
outTrueList := e :: outTrueList;
else
elseif isPresent(outFalseList) then
outFalseList := e :: outFalseList;
end if;
end while;
Expand Down Expand Up @@ -1600,14 +1600,14 @@ algorithm
for e in inList1 loop
if isMemberOnTrue(e, inList2, inCompFunc) then
outIntersection := e :: outIntersection;
else
elseif isPresent(outList1Rest) then
outList1Rest := e :: outList1Rest;
end if;
end for;

outIntersection := listReverseInPlace(outIntersection);
outList1Rest := listReverseInPlace(outList1Rest);
outList2Rest := setDifferenceOnTrue(inList2, outIntersection, inCompFunc);
outList1Rest := if isPresent(outList1Rest) then listReverseInPlace(outList1Rest) else {};
outList2Rest := if isPresent(outList2Rest) then setDifferenceOnTrue(inList2, outIntersection, inCompFunc) else {};
end intersection1OnTrue;

public function setDifferenceIntN
Expand Down

0 comments on commit a391fa9

Please sign in to comment.