[Libreoffice] unicode string literals, "stack" strings etc.
michael.meeks at novell.com
Thu Jan 20 08:43:17 PST 2011
This is about to drop off the end of my mailbox I suppose :-)
On Fri, 2010-10-29 at 09:49 +0100, Caolán McNamara wrote:
> Taking unostrings.cxx there's some template cunning which generates
> objects with the same layout as a OString, but without any constructors,
> so that the StaticInit_OString macro generates OString-alike objects
> which require effectively 0 setup time and can be shoved by the linker
> into the rodata section.
Looks fun; particularly for existing, global, static strings that
require the link-time constructors running before we can execute code.
Then again - I wonder whether we should be linking more of our code
into a "great big blob" library - like mozilla does: if only to help
with the I/O scheduling :-)
> Catch is though, that because OStrings and OUStrings do shallow copies,
> copying one of these magic-strings about the place leaves it very
> possible that a shallow-copy of the string will outlive the "stack
> string" and die horribly. So to be safe the OString/OUString copy
> methods would have to be tweaked to do a deep copy when one of these
> shows up.
Right; which could loose us any performance advantage. Still I'd really
like this feature to be able to use in the XML parsing world where most
strings are allocated, and immediately thrown away (though FastParser
improves this somewhat). So - we could have blocks of static stack
allocated strings that we could pass out into the app quickly - without
any atomic ref-counting sillies etc.
> A big plus I see here is the potential to remove the very large
> number of string constructors which are run during startup.
Do you have good metrics for that number ? I wonder - if we could write
some small piece of perl/shell that would simply print that number out,
(presumably just the sum of all the .init section sizes in each object
file) ? and then ask people to help shrink that number ?
And/or just wondering what the longer-term master plan is here.
michael.meeks at novell.com <><, Pseudo Engineer, itinerant idiot
More information about the LibreOffice