In article <3dfe1e0d@news.povray.org>, Micha Riser <mri### [at] gmxnet>
wrote:
> They hide what is really going on when using them.
That is a good thing. It is no different from using a function or
abstract object, it hides information that is irrelevant.
> Sometimes there is also an additional temporary variable created.
You are micro-optimizing...though I am sometimes guilty of that too.
A good compiler can often figure out the most efficient way to compile
the code.
> will have to be tranlated by the compiler to
> tmp = c;
> tmp += b;
> a += tmp;
> as it cannot assume that (a+b)+c is the same as a+(b+c). On the other hand
> a.add(b); a.add(c);
> does not need a temporary variable.
a += b; a += c;
or:
(a += b) += c;
No temporaries.
The version using operator overloading is much easier to read, and the
compiler could probably optimize away any significant differences.
--
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/
Post a reply to this message
|