[Libreoffice-commits] core.git: sc/source

Muhammet Kara muhammet.kara at pardus.org.tr
Wed Jan 4 15:56:35 UTC 2017


 sc/source/filter/html/htmlexp.cxx |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

New commits:
commit 4dad0c5b1ee1a243fbccd45ef2fc97b78aaa30a2
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Tue Dec 27 17:29:44 2016 +0300

    Refactor lcl_makeHTMLColorTriplet
    
    - Reduce the unnecessarily large buf size
    - Replace multiple occurences of sprinf with only one snprintf
    - Avoid some unnecessary variable creations
    
    Change-Id: I14f36bea8eed10a62fbf977f10b148c8c52ad2ca
    Reviewed-on: https://gerrit.libreoffice.org/32451
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
index 4177226..f3fa0cb 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -183,16 +183,12 @@ static void lcl_AddStamp( OUString& rStr, const OUString& rName,
 
 static OString lcl_makeHTMLColorTriplet(const Color& rColor)
 {
-    OStringBuffer aStr( "\"#" );
+    sal_Char    buf[24];
+
     // <font COLOR="#00FF40">hello</font>
-    sal_Char    buf[64];
-    sal_Char*   p = buf;
-    p += sprintf( p, "%02X", rColor.GetRed() );
-    p += sprintf( p, "%02X", rColor.GetGreen() );
-    sprintf( p, "%02X", rColor.GetBlue() );
-    aStr.append(buf);
-    aStr.append('\"');
-    return aStr.makeStringAndClear();
+    snprintf( buf, 24, "\"#%02X%02X%02X\"", rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue() );
+
+    return OString(buf);
 }
 
 ScHTMLExport::ScHTMLExport( SvStream& rStrmP, const OUString& rBaseURL, ScDocument* pDocP,


More information about the Libreoffice-commits mailing list