.MetaModelica.referenceEq

Information

This is a very fast comparison of two values which only checks if the pointers are equal.

The intended way of using the function is to speed up comparisons.

If you know that all occurances of REC(1.5) are the same pointer (e.g. if you made a pass on your datastructure that replaced all occurances with a single one), you can use referenceEq instead of structural equality (valueEq or a user-provided comparison).

You can also use the function to speed up comparsions if the rate of success is expected to be high or the cost of structural equality is high. But then you need to do a structural equality check after to make sure nothing is wrong.

You can use the function to avoid reconstructing an identical datastructure on traversals, which saves memory and time spent on garbage collection: case rec as REC(x) equation nx = f(x); then if referenceEq(x,nx) then rec else REC(nx);

Interface

function referenceEq<A>
  input A a1;
  input A a2;
  output Boolean b;
end referenceEq;

Generated at 2024-04-19T18:16:02Z by OpenModelicaOpenModelica 1.22.3 using GenerateDoc.mos