Efficient string concatenation

Norbert Thiebaud nthiebaud at gmail.com
Sun Dec 2 20:41:05 PST 2012


On Sun, Dec 2, 2012 at 4:56 PM, Lubos Lunak <l.lunak at suse.cz> wrote:
>

in pathc 0001:

+#ifdef RTL_FAST_STRING
+    template< typename T1, typename T2 >
+    OStringBuffer( const OStringConcat< T1, T2 >& c )
+    {
+        const int l = c.length();
+        rtl_String* buffer = NULL;
+        rtl_string_new_WithLength( &buffer, l );
+        char* end = c.addData( buffer->buffer );
+        buffer->length = end - buffer->buffer;
+        pData = buffer;
+        nCapacity = l + 16;
^^^^ how does that work ? you allocate l-bytes but declare a capacity
of l + 16 ????

Norbert


More information about the LibreOffice mailing list