Bug 62096 - Replace O(U)String compareTo with ==
Summary: Replace O(U)String compareTo with ==
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: Other All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:4.1.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Blocks:
 
Reported: 2013-03-10 11:02 UTC by Thomas Arnhold
Modified: 2015-12-16 00:43 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Arnhold 2013-03-10 11:02:31 UTC
There are many uses of compareTo, like "str1.compareTo(str2) == 0" which can be replaced with there better understandable equivalents "str1 == str2" or "str1.equals(str2)".

Here are two grep statements to find some of them:

git grep '\.compareTo\s*([^)]*)\s*==\s\(0\|COMPARE_EQUAL\)'

-> lhs.Name.compareTo(rhs) == 0


git grep '\(0\|COMPARE_EQUAL\)\s*==\s*[a-zA-Z0-9]\+\.compareTo\s*([^)]*)'

-> 0 == url.compareTo( EXPAND_PROTOCOL ":" )

Those could be replaced with "str1 == str2". There are many other uses like with != and more. If you need help to find them or to adapt the grep statements please ask me!
Comment 1 Stephan Bergmann 2013-03-11 08:56:20 UTC
...but be aware that the two-parameter form of compareTo is more related to startsWith and to operator ==
Comment 2 Stephan Bergmann 2013-03-11 09:21:58 UTC
(In reply to comment #1)
> ...but be aware that the two-parameter form of compareTo is more related to
> startsWith and to operator ==

*than* to operator ==
Comment 3 Commit Notification 2013-03-31 15:47:01 UTC
Efe Gürkan YALAMAN committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=52770659d33f8f08a769043392cfb5a926019fef

fdo#62096 Replace O(U)String compareTo with ==



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:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 4 Lior Kaplan 2013-04-05 10:11:44 UTC
This commit wasn't notified automatically:
http://cgit.freedesktop.org/libreoffice/core/commit/?id=e1f6dac6893e0ad9e1b1f03a3b882cf1e9a08d32
Comment 5 Commit Notification 2013-04-10 08:16:07 UTC
Prashant Pandey committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8398d5d9ac0f169ee7a045f6677919c79a5cbe0f

fdo#62096: Replaced some OUString 'compareTo' with '=='



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:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2013-04-17 10:04:56 UTC
Artur Dryomov committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b80d8c695e6b6ded231e67ed9a80bcd1f1250c03

fdo#62096 - replace some O(U)String compareTo with ==



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:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2013-04-19 20:35:17 UTC
Janit Anjaria committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f51450717d4e639bd8af81c7d1ed13cc08e57e22

fdo#62096 Replace OUString compareTo with == operator



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:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2013-04-19 20:42:25 UTC
Janit Anjaria committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b444e459c8a3e39c36e7cf6854bd1eae92b0e81a

fdo#62096 Replace O(U)String compareTo with ==



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:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2013-04-22 07:28:48 UTC
Sameer Deshmukh committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=560e4fd02f8a4a3e26b3810b12d02a2d2e78593f

fdo#62096 - Changed a few compareTo's to '=='



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:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2013-04-22 07:36:48 UTC
Sameer Deshmukh committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ca54015d7ea10f5648bccb2adfb7a321747e70f9

fdo#62096 Corrected stupid error in previous patch



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:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2013-04-22 07:44:48 UTC
Sameer Deshmukh committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=dd47994722eaead16099145e593fbf878072d52b

fdo#62096: Replaced some compareTo with ==



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:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 12 Commit Notification 2013-04-22 07:57:52 UTC
Fridrich Å trba committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ff4464659ec54732c45729ace964d60e77d19eb2

Revert "fdo#62096: Replaced some compareTo with =="



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:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 13 Artur Dryomov 2013-06-14 15:51:45 UTC
Thomas, can this bug be considered as fixed? I cannot find anything using your grep statements at master.
Comment 14 Thomas Arnhold 2013-06-14 18:43:09 UTC
Wonderful :)

I'm closing it.
Comment 15 Robinson Tryon (qubit) 2015-12-16 00:43:49 UTC
Migrating Whiteboard tags to Keywords: (EasyHack,SkillCpp,TopicCleanup,DifficultyBeginner )
[NinjaEdit]