vcl/source/fontsubset/sft.cxx |   37 ++++++++++++-------------------------
 1 file changed, 12 insertions(+), 25 deletions(-)

New commits:
commit 7b2e3772cf1b795efe4791ed0c8de67729fe2366
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Aug 1 09:44:19 2025 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Aug 1 14:59:37 2025 +0200

    Simplify nameExtract a bit
    
    Change-Id: Iae10606082645189aa81476c970dced55d3107a0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188741
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 83438f6fbedc..cfee9552ed0e 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -616,7 +616,9 @@ static int GetTTGlyphOutline(AbstractTrueTypeFont *ttf, 
sal_uInt32 glyphID, std:
 
 static OString nameExtract( const sal_uInt8* name, int nTableSize, int n, int 
dbFlag, OUString* ucs2result )
 {
-    OStringBuffer res;
+    if( ucs2result )
+        ucs2result->clear();
+
     const sal_uInt8* ptr = name + GetUInt16(name, 4) + GetUInt16(name + 6, 12 
* n + 10);
     int len = GetUInt16(name+6, 12 * n + 8);
 
@@ -625,13 +627,10 @@ static OString nameExtract( const sal_uInt8* name, int 
nTableSize, int n, int db
     const int available_space = ptr > end_table ? 0 : (end_table - ptr);
     if( (len <= 0) || len > available_space)
     {
-        if( ucs2result )
-            ucs2result->clear();
         return OString();
     }
 
-    if( ucs2result )
-        ucs2result->clear();
+    OStringBuffer res;
     if (dbFlag) {
         res.setLength(len/2);
         for (int i = 0; i < len/2; i++)
@@ -651,8 +650,7 @@ static OString nameExtract( const sal_uInt8* name, int 
nTableSize, int n, int db
             *ucs2result = buf.makeStringAndClear();
         }
     } else {
-        res.setLength(len);
-        memcpy(static_cast<void*>(const_cast<char*>(res.getStr())), ptr, len);
+        memcpy(res.appendUninitialized(len), ptr, len);
     }
 
     return res.makeStringAndClear();
commit 045b99508edfefb1f1b7a8ef3329ba5466518571
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Aug 1 09:42:11 2025 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Aug 1 14:59:26 2025 +0200

    Simplify GetInt* a bit, using respective GetUInt*
    
    Change-Id: I1ef3c8dbf132504ea3529a1d51f188b1c44c57c9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188740
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 0420dfadcd11..83438f6fbedc 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -74,16 +74,6 @@ struct TTGlyphMetrics {
 }
 
 /*- Data access methods for data stored in big-endian format */
-static sal_Int16 GetInt16(const sal_uInt8 *ptr, size_t offset)
-{
-    sal_Int16 t;
-    assert(ptr != nullptr);
-
-    t = (ptr+offset)[0] << 8 | (ptr+offset)[1];
-
-    return t;
-}
-
 static sal_uInt16 GetUInt16(const sal_uInt8 *ptr, size_t offset)
 {
     sal_uInt16 t;
@@ -94,15 +84,9 @@ static sal_uInt16 GetUInt16(const sal_uInt8 *ptr, size_t 
offset)
     return t;
 }
 
-static sal_Int32  GetInt32(const sal_uInt8 *ptr, size_t offset)
+static sal_Int16 GetInt16(const sal_uInt8* ptr, size_t offset)
 {
-    sal_Int32 t;
-    assert(ptr != nullptr);
-
-    t = (ptr+offset)[0] << 24 | (ptr+offset)[1] << 16 |
-        (ptr+offset)[2] << 8  | (ptr+offset)[3];
-
-    return t;
+    return static_cast<sal_Int16>(GetUInt16(ptr, offset));
 }
 
 static sal_uInt32 GetUInt32(const sal_uInt8 *ptr, size_t offset)
@@ -116,6 +100,11 @@ static sal_uInt32 GetUInt32(const sal_uInt8 *ptr, size_t 
offset)
     return t;
 }
 
+static sal_Int32 GetInt32(const sal_uInt8* ptr, size_t offset)
+{
+    return static_cast<sal_Int32>(GetUInt32(ptr, offset));
+}
+
 static F16Dot16 fixedMul(F16Dot16 a, F16Dot16 b)
 {
     return fix16_mul(a, b);

Reply via email to