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


On 03/19/2012 07:30 AM, Noel Grandin wrote:
Even in Java, it's a code smell to allocate a StringBuffer object
without specifying a pre-allocation size.

Is it?

Might make a good EasyHack to go through the code and change the places
that allocate OUStringBuffer to give them a reasonable initial size?

Problem is, with the various (incl. signed vs. unsigned) integral types around, it is often not easy to write an expression for initial rtl::OUStringBuffer capacity that is both reasonably short and correct (i.e., not prone to trigger undefined behaviour for signed sal_Int32) -- and also does not cause warnings when compiled on any platform.

Therefore, it is often much simpler to go without a pre-computed capacity and accept the log N reallocation hit.

Stephan

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.