[Libreoffice] message construction bloat ...

Lubos Lunak l.lunak at suse.cz
Wed Nov 23 08:55:38 PST 2011


On Wednesday 23 of November 2011, Michael Meeks wrote:
> On Wed, 2011-11-23 at 14:56 +0100, Lubos Lunak wrote:
> >  And some of the arguments are rather weak as well, I can get you easy to
> > use and read, better to translate and similarly space efficient without
> > var-args. Wanna bet :) ?
>
> 	Sounds great to me; of course - it'd be nice if it compiled in linear
> time too without including a million lines of odd boost templated
> headers ;-) but certainly; if we can get something readable, and
> typesafe that compiles to something -actually-small- - ie. a single
> function call & setup; I'm all for it whatever it looks like - it sounds
> like the best of all worlds.

 I haven't thought it out in detail, but the general idea is attached. It's 
just a proof of concept, so there are some obvious problems, but I don't see 
a flaw in the design. Since it's also just a single call, the in-place cost 
is small and is moved to the bodies of the templates, which can be just in 
one place, one per each combination of arguments (and the common instances of 
the template can be externed, so it really will be just one copy). The 
template code is relatively small, so I don't expect noticeable impact on 
compile time. Also, funnily enough, the generated code in the place of the 
call is one instruction shorter, because unlike printf() it does not need the 
terminating NULL for the vararg :).

 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.

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


More information about the LibreOffice mailing list