Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


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)
vector<T>(vec).swap(vec);

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.

Best,

Kohei



Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.