[Libreoffice] message construction bloat ...

Lubos Lunak l.lunak at suse.cz
Thu Nov 24 11:49:21 PST 2011


On Wednesday 23 of November 2011, Lubos Lunak wrote:
>  I expect it would be even possible to achieve such single in-place call
> even for the LOG( "P is " << p << " and b is " << b ) case, or even do this
> for string+string operation, which would turn it into the even
> better-looking LOG( "P is " + p + " and b is " b ) or LOG( "P is %1 and b
> is %2", p, b ), whichever would suit one's fancy (as in, both would be
> possible at the same time). It would require getting a bit more creative
> with argument and return types for the operator overloads, but that'd be
> hidden behind the scenes.

 Oh well, I guess I couldn't resist the temptation to try at least a proof of 
concept. The attached testapp (depending on #define OPT) compiles things like 
string1 + "foo" + string2 + "bar" + string3 into a call to a single function 
which allocates just a single string object for the result of the operation, 
no intermediate string objects or allocations are required.

 So it indeed looks doable and we can have efficient and at the same time not 
ackward to use string operations. Something for the next Hackweek or so.

 Could somebody try that it works with the Windows compiler as well?

-- 
 Lubos Lunak
 l.lunak at suse.cz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: b.cpp
Type: text/x-c++src
Size: 4525 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20111124/92ef3131/attachment.cpp>


More information about the LibreOffice mailing list