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

--- Comment #5 from David Tardon <[email protected]> ---
(In reply to comment #4)
> Fair cop - but for very high frequency things like the OOXML attributes /
> values etc. [ the ones tackled so far are ~never used sadly ;-] - I want
> intrusive pointers for 2x reasons:
> 
> a) to avoid allocations and
> b) to avoid atomic interlock operations on ref counting
> 
> We should never be allocating / ref / unref'ing one of two boolean values
> eg. ;-)

So I would say that tweaking the smart ptr. impl. goes in a wrong way. What is
needed is to avoid direct use of ctors and new/make_shared and instead use
creator functions than can do some extra work to avoid needless allocations.
E.g., someting like the following would ensure there are never more than 2
allocations of objects of OOXMLBooleanValue:

OOXMLValue::Pointer_t OOXMLBooleanValue::create(bool val)
{
    if (val)
    {
        static OOXMLValue::Pointer_t aTrue(new OOXMLBooleanValue(val));
        return aTrue;
    }
    else
    {
        static OOXMLValue::Pointer_t aFalse(new OOXMLBooleanValue(val));
        return aFalse;
    }
}

(Of course, for this to really work, clone() would have to be changed to return
Pointer_t as well. But I do not think that naked pointers are used anywhere at
all, so this is not a problem.)

OOXMLIntegerValue and the few others that wrap intergers could use some sort of
cache.

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

Reply via email to