https://bugs.freedesktop.org/show_bug.cgi?id=80908

          Priority: medium
            Bug ID: 80908
          Assignee: libreoffice-bugs@lists.freedesktop.org
           Summary: avoid allocating OOXMLValues when we don't need to ...
          Severity: normal
    Classification: Unclassified
                OS: All
          Reporter: michael.me...@collabora.com
          Hardware: Other
            Status: UNCONFIRMED
           Version: 4.3.0.0.beta1
         Component: Writer
           Product: LibreOffice

We spend quite a lot of time on import allocating and quickly freeing again XML
properties; eg.

class OOXMLBooleanValue : public OOXMLValue
{
protected:
    bool mbValue;

which can only really hold two states.

Instead we should have a pair of these values and simply return either a shared
pointer to them or (better) as/when bug#80907 is fixed - have 2x static
versions on the stack with an initial ref count set such that they are never
destroyed [ in the meantime I guess a static boost::shared_ptr and a static
boost::shared_ptr< > Create(bool bBool); type API might make some sense.

Then of course there is the:

class OOXMLIntegerValue : public OOXMLValue
{
protected:
    sal_Int32 mnValue;

I strongly suspect that integer values such as '0' and '1' are some large
proportion of these guys; and also our string -> integer conversion is not
ultra-fast for single digits; so I would attack:

                case RT_Integer:
                    {
                        sal_Int32 nValue;
                        pAttribs->getAsInteger(nToken,nValue);
                        OOXMLValue::Pointer_t xValue(new
OOXMLIntegerValue(nValue));

This code, and instead get the NULL terminated string from pAttribs (cf. the
context there) - and pass it to a Create method.

That method could then easily special case single character integers returning
a reference to a static array of 10x of them - accelerating the common case,
avoiding allocation, and falling back to the slower string->int conversion.

Just some thoughts there;

Thanks !

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
Libreoffice-bugs@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to