From eb3dd8fbb2ffd8465dcfd43f81445489054e91e5 Mon Sep 17 00:00:00 2001 From: Muhammet Kara Date: Mon, 26 Dec 2016 13:43:15 +0300 Subject: 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 Reviewed-by: Julien Nabet (cherry picked from commit 8885343a33365d2570513073c3666428aa79dbdf) (cherry picked from commit 0f839fba28a2e50d5bfa0a131c68d493903045c0) --- desktop/source/lib/init.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop') 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()) -- cgit