Created attachment 54059 [details] plugin script Lots of calls to rtl::OString/rtl::OUString getLength() check whether the string is empty, something that can be expressed more cleanly with calling isEmpty() instead. The attached emptylength.py can be used with <https://fedorahosted.org/gcc-python-plugin/> to find such calls at compile time. See the script for further details. The attached emptylength.txt contains the notes produced by the plugin on a recent unxlngx6 (--enable-dbgutil) master (towards LO 3.5) build. As mentioned in emptylength.py: "The re-constructed original comparison and the suggested improvement should be taken with a grain of salt." And: "Produces false positives [...]" But it should be a helpful starting point.
Created attachment 54060 [details] log
Hi The main issue with this Easy Hack is to control the 8451 occurences of the target string, where no automated replacement is recomended (false positives), so the job has to be done with extreme care. No-brainer but very extensive. My suggestion: chunks per module (e.g. basctl, basic, avmedia, etc...) Besides a simple compilation/build, is there a way to test the results? The occurence spans all over the application. Advise welcome
Re comment 2, what do you mean with "the 8451 occurences of the target string, where no automated replacement is recomended (false positives)"? Can you give a link to one of those 8451 occurrences?
Number of lines of the log file in comment#1. AFAIK, each line must be inspected... did I missed something?
Now I got you. Yes, there are false positives (I found at least one, as documented), and there might be cases where the replacement suggestion's negation-status (i.e., whether or not to prefix isEmpty() with !) is wrong, due to the original getLength() comparison already being re-written by the compiler's optimization steps. But if this could blindly be done mechanically, it would already have been done so. :)
<http://cgit.freedesktop.org/libreoffice/core/commit/?id=f43311dfb77342f0d003bee5336215f92500f15c> addresses occurrences in UnoControls, accessibility, and avmedia.
Module basctl http://cgit.freedesktop.org/libreoffice/core/commit/?id=1688a9d9235dd2ee4f3b9497308efd41f7a3fb6f
Module basic http://cgit.freedesktop.org/libreoffice/core/commit/?id=91d4fe75eed800fd37211555b09cac0af3b1d640
Module basic (small cosmetic fix per demand of Ivan Timofeev) binaryurp bridges http://cgit.freedesktop.org/libreoffice/core/commit/?id=9201704ede70498a850bee6d15f0340d58f3889c
Module chart2 pushed: http://cgit.freedesktop.org/libreoffice/core/commit/?id=0eac98aa742e8e76ebb1af91b32bd02e04b2e20a
Module codemaker http://cgit.freedesktop.org/libreoffice/core/commit/?id=fd866ac8f184c0910883963c9c12b45a239a9227
Module comphelper http://cgit.freedesktop.org/libreoffice/core/commit/?id=00a67c0f9056729695e6004707d64b448756fa6f
Module configmgr http://cgit.freedesktop.org/libreoffice/core/commit/?id=4a0ab53cf44be11053a095470ad8cb426487dbc6
Module connectivity http://cgit.freedesktop.org/libreoffice/core/commit/?id=1777c09a0781710c309e500f680e6f95c080ca86 http://cgit.freedesktop.org/libreoffice/core/commit/?id=198a99861e14cf5c001177b1192cebfe4708ea05 http://cgit.freedesktop.org/libreoffice/core/commit/?id=d18daeff771b255207bb30d428540d9ebd28ec32
Modules cppu cppuhelper cpputools http://cgit.freedesktop.org/libreoffice/core/commit/?id=1b99d8800e399f45404ab62827163a873d2a1aec
Module cui http://cgit.freedesktop.org/libreoffice/core/commit/?id=1375183d465fb17db513dfe16ac522e48573a4c0
Module dbaccess http://cgit.freedesktop.org/libreoffice/core/commit/?id=545921f914ec172bcd6712cce54847131a49afb6
Module desktop http://cgit.freedesktop.org/libreoffice/core/commit/?id=1835d0599e3d8984c7dfa2bbef2be5747596716a
Module embeddeobj http://cgit.freedesktop.org/libreoffice/core/commit/?id=7c0c3362de894ddd4526f56e1849f116eb25cedd
Module Extensions http://cgit.freedesktop.org/libreoffice/core/commit/?id=0fd40fe17bf67f81db44ef187ce67193ba1696cb
modules drawinglayer, dtrans, editeng http://cgit.freedesktop.org/libreoffice/core/commit/?id=b575f4b1a2a2217282cddc995951b350936b47b1
Modules fileaccess filter http://cgit.freedesktop.org/libreoffice/core/commit/?id=e7bddf732798508e347221590110486e97bb45e6
Modules formula fpicker http://cgit.freedesktop.org/libreoffice/core/commit/?id=3e4f51f112248b4e586f5bd86388099737ed17e9
Module forms http://cgit.freedesktop.org/libreoffice/core/commit/?id=6cfae09e5dafa477db210272949e253d4fb24349
module frameowrk http://cgit.freedesktop.org/libreoffice/core/commit/?id=18692cc1412bd7eca37d80d4345c0ae775d94ac5
module i18npool, idl, idlc, io, javaunohelper, jvmaccess http://cgit.freedesktop.org/libreoffice/core/commit/?id=a17fb882569046cd9f6940cf2e87435200bb666b
Modules linguistic http://cgit.freedesktop.org/libreoffice/core/commit/?id=c3fc5c9c9b17cef63fa7c77a39a0971c27a004f9
Modules lotuswordpro http://cgit.freedesktop.org/libreoffice/core/commit/?id=74e2d9b1e070a09cbbecfa305797566496420a01
Module oox http://cgit.freedesktop.org/libreoffice/core/commit/?id=6af59644d6508049409a03d1c4a598ea2bef521e
Module package http://cgit.freedesktop.org/libreoffice/core/commit/?id=829db12d7e3e93b4a44f79b39a0a9f0630439109
Modules padmin, pyuno, rdbmaker, regexp, registry, rsc, sal http://cgit.freedesktop.org/libreoffice/core/commit/?id=85d1ce27ad9ce7a3740bd8bbbaf1d3abe643ba10
Module reportdesign http://cgit.freedesktop.org/libreoffice/core/commit/?id=e224197bda4fc17b0a2333a2af69c11577ec3ef4
Modules jvmfwk, l10ntools, lingucomponent http://cgit.freedesktop.org/libreoffice/core/commit/?id=c47f3523338b8e58c1ea18cc583064761f60df90
Modules sax, scaddins, sccomp, scripting http://cgit.freedesktop.org/libreoffice/core/commit/?id=fffd541c3e626bee162ab4b473b6bd6cd180244e
Module sd http://cgit.freedesktop.org/libreoffice/core/commit/?id=db08c1ac5ed566fbec4d2ce8345ed483fa8bf9ab
Module sfx2 http://cgit.freedesktop.org/libreoffice/core/commit/?id=e24a27b4cc920cbb1b87c33f99b7379f50d2e0f7
MOdule sdext http://cgit.freedesktop.org/libreoffice/core/commit/?id=f19d269
Modules shell, slideshow, sot, starmath http://cgit.freedesktop.org/libreoffice/core/commit/?id=806dce17d6631738c7388d8d68d8b5ac2e4c11a8
Module stoc http://cgit.freedesktop.org/libreoffice/core/commit/?id=71dc235
Modules svl http://cgit.freedesktop.org/libreoffice/core/commit/?id=38423e0ad2a8e2a902aeb37391aef0b543c09d68
Modules svtools http://cgit.freedesktop.org/libreoffice/core/commit/?id=ad6ce5e938ce9d78bed9ce6dead5fa087de49c63
Modules svx http://cgit.freedesktop.org/libreoffice/core/commit/?id=dc04d67e94d9302278fc049d6617b62fe461ac66
Modules testtools, toolkit, tools http://cgit.freedesktop.org/libreoffice/core/commit/?id=81e50fb2e378120d05f7ffdee216ce6e248e189b and extra mistake fix http://cgit.freedesktop.org/libreoffice/core/commit/?id=de8c830947a756b6d8ab2d7ef33934c9ba28036a
Module sw http://cgit.freedesktop.org/libreoffice/core/commit/?id=964617156260cd157d4f39be01a5d3dec1c29a27
Modules ucbhelper, unodevtools http://cgit.freedesktop.org/libreoffice/core/commit/?id=55b6485978bbfe17c1355909a5e27d8c846a4ee8 Modules unotools http://cgit.freedesktop.org/libreoffice/core/commit/?id=6a1390eaf6464e71668c402d262a21c9192278e9 Modules unoxml http://cgit.freedesktop.org/libreoffice/core/commit/?id=5738e07a78c5894d111ee6c6e0d07b56ff126b2c Modules uui http://cgit.freedesktop.org/libreoffice/core/commit/?id=c571e8777d15fd1c3f8730a7c1325d75c746333d
Module many modules(inc's) http://cgit.freedesktop.org/libreoffice/core/commit/?id=558112542348bcbd754853847c968e2203abf269 Modules writerfilter, writerperfect http://cgit.freedesktop.org/libreoffice/core/commit/?id=f94399ef8023ad3b21528ecdc00e44366d4c3fe5
Modules xmlhelp http://cgit.freedesktop.org/libreoffice/core/commit/?id=2727a29e57cdcd5dddc94a829194f88cfc2808ab Modules xmloff (part 1) http://cgit.freedesktop.org/libreoffice/core/commit/?id=4228c5542b57b43064bbefb3cc79c4eb51e059d6 Modules xmloff (part 2) http://cgit.freedesktop.org/libreoffice/core/commit/?id=3dbb89e5a39e7811d2fc0c1fbad012c3d565396b Modules xmloff (part 3) http://cgit.freedesktop.org/libreoffice/core/commit/?id=dfa8287f8bbb6c523266237ff67eb4b3d07b5c8b Modules xmloff (part 4) http://cgit.freedesktop.org/libreoffice/core/commit/?id=596469d4183ff451833348cb4454ad0d02e0138f Modules xmloff (part 5) http://cgit.freedesktop.org/libreoffice/core/commit/?id=983de9808159036bd5de008d895ba6e5566c99f6 Modules xmloff (part 6) http://cgit.freedesktop.org/libreoffice/core/commit/?id=260054594c91af05f2825d512801200797d10075 Modules xmlscript http://cgit.freedesktop.org/libreoffice/core/commit/?id=9d4e1a5dadede021922abcb00d346fe496240ab4 Modules xmlsecurity http://cgit.freedesktop.org/libreoffice/core/commit/?id=9d4e1a5dadede021922abcb00d346fe496240ab4
Modules vbahelper http://cgit.freedesktop.org/libreoffice/core/commit/?id=7f585002c460a095693eeec4453b869b3915118b Modules vcl (part 1) http://cgit.freedesktop.org/libreoffice/core/commit/?id=0a112c96fd8077a027dac88510915eb93903748b Modules vcl (part 2) http://cgit.freedesktop.org/libreoffice/core/commit/?id=634820b3a8604dd1ed868ddeffc2501f3a0f056f Modules vcl (part 3) http://cgit.freedesktop.org/libreoffice/core/commit/?id=beccf7c9dd4966347fa31e11922fd73bd40dfeb9
At this point I have parsed all entries of the log file of comment #1, with the exception of binfilter (which is expected to become deprecated or with no further development). @ Stephan Bergman: Can you run the script once more to generate a last log, just to catch the replacements I may have left? Thank you.
nice to see this linked in your slides Stephan :-) be even better to double check the last bits & get this closed [ if that's easy ].
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=a2454a42ad2236f0f6b88be166bc7e6a8f90f036 fdo#43460: use isEmpty() 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.
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=d2f57b6c1275e0e6ed7f214d471ddb84ecb1b4ad fdo#43460: use isEmpty() 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.
Created attachment 76242 [details] plugin script (with StringBuffer)
Thomas Arnhold committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=6dddefc6e7ff6dc5cde46dde069ba1d7db4ac34b fdo#43460: use isEmpty() 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.
I've reopened it, because it also applies to O(U)StringBuffer now.
Ok I am working on replacing O(U)StringBuffe. I am recompiling LO with the python plugin atm.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=040710161c507f6e4d0120cfb61d9d82bc6a0527 fdo#43460 use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=d30df91b1e5ce90826a96e4f494791c0b61b8b7c fdo#43460 chart2: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=97460c421abec14150c4ddde27daeef892c86b16 fdo#43460 configmgr: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=2f731e7a19f2c36da64b9631cf4f2de0f6d2a86e fdo#43460 startmath,codemaker: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=9a95669e5035758fc115f4c7be3e0a00651fe993 fdo#43460 dbaccess: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=af7cfa0071f5b2be33e9b887e6221c5047d21262 fdo#43460 forms: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=50e6713e40cd239f7e568f00ad7adf44bda3453f fdo#43460 oox: use isEmpty() 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.
Chr. Rossmanith committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=f8d1dcc621b04fd17577905e9b1bdf71f33c7b57 fdo#43460: Use isEmpty() instead of getLength() in svgio 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=733d88433c560af8f51f010fcaae9ce7a29b0325 fdo#43460 tools: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=5883e1926b80334cfdb7a3dd63d6391b1738c2a6 fdo#43460 sw: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=caab53cf21bc38ead3927941795b3c8a1432589a fdo#43460 connectivity,extensions,filter,idl,idlc: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=84f1f1d149b6ba95aca8adb7e34b001e102f07fe fdo#43460 include,registry,svtools,svx,unodevtools: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=ad09b2f7efac628ac4261b86f9fd085f83ebe717 fdo#43460 xmloff: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=b5f3f55ce59b400f885c41413a3087e3406a424d fdo#43460 unoxml,writerfilter,xmlsecurity: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=34f50399f1bc896849a0e3fc3598ab1225d760c5 fdo#43460 shell,vcl,xmlreader: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=97f71c5f8be85f47d7978259a2d82708412043fd fdo#43460 svl: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=51daa4de4fbb86903aeb9cdfefbb089e8d00c001 fdo#43460 sd,rsc,ucb,sdext: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=126827b0fdc2277d728d57d4fe68b446fa2f7a08 fdo#43460 framework,i18npool,accessibility: use isEmpty() 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.
Jelle van der Waa committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=f042e22f535e3143332eb788f908f06900eeb40d fdo#43460 sc: use isEmpty() 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.
Chr. Rossmanith committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=82a1d75ee59c46e6bb361b98c520cc4eff2e770c fdo#43460: Use isEmpty() instead of getLength() in svgio 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.
I think this easyhack can be closed since the only three occurrences I get when recompiling core. And those occurrences seem valid. core/basegfx/source/polygon/b2dsvgpolypolygon.cxx:179:17: note: [EmptyLength plugin] replace "getLength() > 0" with "!isEmpty()" core/svl/source/numbers/zformat.cxx:2492:21: note: [EmptyLength plugin] replace "getLength() == 0" with "isEmpty()" core/vcl/unx/x11/x11sys.cxx:111:9: note: [EmptyLength plugin] replace "getLength() > 0" with "!isEmpty()"
thanks everybody for working on this
Migrating Whiteboard tags to Keywords: (EasyHack) [NinjaEdit]