[LyX/master] Make cell index of tabular local for column loop.

Pavel Sanda sanda at lyx.org
Wed Feb 12 16:05:25 UTC 2020

On Wed, Feb 12, 2020 at 08:50:13AM -0500, Scott Kostyshak wrote:
> Is it true that without optimization, this change would be less
> efficient because cell has to be recreated (so memory allocated) on each
> iteration of the for loop? But is the idea that compilers recognize this
> and only allocate memory once so that in practice there is no loss in
> efficiency?

I am no expert of what nowadays compilers do in backgrounds but if the variable
was a simple type like integer then there is really no memory allocation
business going on, because you are on stack. Stack pointer might decrease, that
should be all.
Contrary is the case when you get new variable on heap via new/malloc/...

When the variable is class I can imagine things could go south when
someone would define copy constructor and assignment operator with
strikingly different semantics. But then again, the issue is not
inherently with memory allocation per se...


More information about the lyx-devel mailing list