Bug 86023 - O[U]String needs a 'clear' method ...
Summary: O[U]String needs a 'clear' method ...
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
(earliest affected) rc
Hardware: Other All
: medium normal
Assignee: brij
Whiteboard: target:4.4.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Reported: 2014-11-07 21:52 UTC by Michael Meeks
Modified: 2015-12-15 23:57 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meeks 2014-11-07 21:52:55 UTC
Just looking at a profile, I was struck by the cost of:

OUString aStr;
aStr = OUString();

Where we use the assignment to clear aStr; this in-lines a construction, a de-reference and an assign call ;-) it is done quite a bit too:

git grep ' = OUString()' | nl

it'd be nice to have the obvious cleanup implement a 'clear()' method on OString and OUString thus include/rtl/ustring.hxx and rtl/string.hxx

    void clear()
        rtl_uString_new( &pData );

And then cleanup the call-sites I guess =)

Thanks !
Comment 1 brij 2014-11-09 13:43:05 UTC

I would like to work on this bug. Can you please provide more info about rtl_uString_new( &pData ) method and when will the clear() method be called?

P.S: This is my first bug.

Comment 2 brij 2014-11-09 21:22:41 UTC

I have implemented the clear() method on OString and OUString classes. I will replace appropriate assignments of '= OUString()' to call clear() method.

Can you please suggest how to test it?

Comment 3 Michael Meeks 2014-11-10 06:03:36 UTC
Neato - glad you've done that; wrt. testing - I'd run "make check" in the top-level =) if that works before and after your patch, that's a good sign. The rest is just code-review I think. Looking forward to reading your patch =) please do -only- this change in it; no other cleanups of nearby code etc. [ that makes it much easier to review ].
Comment 4 brij 2014-11-12 18:39:01 UTC

I have pushed the patch to gerrit. Here's the link.


Kindly review.
Comment 5 brij 2014-11-13 20:19:28 UTC

I uploaded the new patch set as per Stephan's comments. Kindly review!
Comment 6 Commit Notification 2014-11-14 08:24:53 UTC
Brij Mohan Lal Srivastava committed a patch related to this issue.
It has been pushed to "master":


fdo#86023 - O[U]String needs a 'clear' method

It will be available in 4.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
Affected users are encouraged to test the fix and report feedback.
Comment 7 Robinson Tryon (qubit) 2015-12-15 23:57:27 UTC
Migrating Whiteboard tags to Keywords: (EasyHack DifficultyBeginner SkillCpp TopicCleanup)