sieve-dev use of references

Shi Jin jinzishuai at gmail.com
Tue Aug 5 17:07:24 CDT 2008


Hi, there,

I am inspecting my code for possible problems. One thing I am suspecting is
the use of reference variables.
In your code, you always use references such as
const Obj<PETSC_MESH_TYPE::sieve_type>  &refSieve=m->getSieve();

In order to reuse this variable many time at different member function of
the USG class, I defined a member variable
Obj<PETSC_MESH_TYPE::sieve_type>  sieve;

And give it value by
sieve=m->getSieve();

This is assuming the mesh is already setup and won't change. If I do
parallel distribution, I will call the above line after the distribution is
complete.

So far it works. But I understand this is a difference: the sieve is
actually an object while the refSieve is just a reference to the mesh's
sieve object.
However, since the ALE::Obj class is very simple, with only three member
variables: objPtr, refCnt, and sz. When sieve=m->getSieve(), I think these
three values are copied. So this should not be a big memory concern. Am I
correct about this?

Thank you very much.
-- 
Sincerely,
Shi Jin, Ph.D.
http://www.ualberta.ca/~sjin1/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.mcs.anl.gov/mailman/private/sieve-dev/attachments/20080805/8e4b234e/attachment.htm>


More information about the sieve-dev mailing list