summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@pardus.org.tr>2016-12-26 13:43:15 +0300
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-12-18 01:07:54 -0500
commiteb3dd8fbb2ffd8465dcfd43f81445489054e91e5 (patch)
treebc9f89835ebbc08a691a948b3ac7727067a7814f
parentconvert DecodeMechanism to scoped enum (diff)
downloadcore-eb3dd8fbb2ffd8465dcfd43f81445489054e91e5.tar.gz
core-eb3dd8fbb2ffd8465dcfd43f81445489054e91e5.zip
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> (cherry picked from commit 8885343a33365d2570513073c3666428aa79dbdf) (cherry picked from commit 0f839fba28a2e50d5bfa0a131c68d493903045c0)
-rw-r--r--desktop/source/lib/init.cxx2
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx2
2 files changed, 2 insertions, 2 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 3cd8e1220753..0256126c19d6 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -394,7 +394,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, SfxLokHelper::MaxTwips, SfxLokHelper::MaxTwips);
if (comphelper::LibreOfficeKit::isPartInInvalidation())
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 6414e2fa5892..fc094c8111e6 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1147,7 +1147,7 @@ callback (gpointer pData)
{
case LOK_CALLBACK_INVALIDATE_TILES:
{
- if (pCallback->m_aPayload.find("EMPTY") != 0) // payload doesn't start with "EMPTY"
+ if (pCallback->m_aPayload.compare(0, 5, "EMPTY") != 0) // payload doesn't start with "EMPTY"
{
GdkRectangle aRectangle = payloadToRectangle(pDocView, pCallback->m_aPayload.c_str());
setTilesInvalid(pDocView, aRectangle);