[Libreoffice-commits] core.git: desktop/source libreofficekit/source
Muhammet Kara
muhammet.kara at pardus.org.tr
Mon Jan 2 10:39:42 UTC 2017
desktop/source/lib/init.cxx | 2 +-
libreofficekit/source/gtk/lokdocview.cxx | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 8885343a33365d2570513073c3666428aa79dbdf
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date: Mon Dec 26 13:43:15 2016 +0300
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 at libreoffice.org>
Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 26c18df..f47970d8 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())
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index a08d93e..cb88bb1 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1136,7 +1136,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);
More information about the Libreoffice-commits
mailing list