Patch to huge memory consumption in LO Calc

Kohei Yoshida kohei.yoshida at
Fri May 30 10:00:04 PDT 2014

Hello Willam,

On Thu, 2014-05-29 at 11:34 +0200, William Bonnet wrote:
> Hello Kohei,
> Thanks for your feedback. I'll do my best to be C++03 compliant for my 
> next patches . So far i haven't found an equivalent to shrink_to_fit, 
> but i think i have another to do it... i'll given it a look during this 
> week end.

With pre-C++11 C++, there is a way to achieve that though it's not as
clean as shrink_to_fit() of C++11.  Referencing Item 17 from "Effective
STL" by Scott Meyers, the following idiom

vector<T> vec;
... (do stuff to increase vec's capacity)

cuts any excess capacity the vec container may have, because
std::vector's copy constructor only allocates to the actual size of the
container and disregards the capacity of the source container.  And the
following swap call puts the copied content back to the original.

> Meanwhile, i think we can improve things a little with the patch i 
> attached to this email.
> If you agree with the solution i proposed, i'll check if other method 
> need the same kind of optimization and i will submit a patch.

Yeah, I think it's reasonable.  So, let's go for that.  It may be
worthwhile to see if we could share this code into a common method if
that's doable.

Also, it would be great to have you adopt the existing brace styles of
mdds.  That would improve the readability of the code in general.



More information about the LibreOffice mailing list