diff options
author | Muhammet Kara <muhammet.kara@pardus.org.tr> | 2016-12-26 13:43:15 +0300 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2017-01-02 10:39:04 +0000 |
commit | 8885343a33365d2570513073c3666428aa79dbdf (patch) | |
tree | 814cbc1b7a2be7df4abfec2b3b432f225985497a /desktop/source/lib | |
parent | 136f5a209e1ca19f7d7b8eb69bb76e7d1b2c07e6 (diff) |
Fix inefficient usage of string::find() in condition (CWE597)
string::compare() will be faster when string::find's result is
compared with 0, because it will not scan the whole string.
Change-Id: I78596a6d796fe9779f88b7c7b91da09aa27b7035
Reviewed-on: https://gerrit.libreoffice.org/32430
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'desktop/source/lib')
-rw-r--r-- | desktop/source/lib/init.cxx | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 26c18dfe34cb..f47970d834bc 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -372,7 +372,7 @@ struct RectangleAndPart static RectangleAndPart Create(const std::string& rPayload) { RectangleAndPart aRet; - if (rPayload.find("EMPTY") == 0) // payload starts with "EMPTY" + if (rPayload.compare(0, 5, "EMPTY") == 0) // payload starts with "EMPTY" { aRet.m_aRectangle = Rectangle(0, 0, INT_MAX, INT_MAX); if (comphelper::LibreOfficeKit::isPartInInvalidation()) |