tools/source/ref/globname.cxx |  100 +++++++++++++++++++-----------------------
 1 file changed, 46 insertions(+), 54 deletions(-)

New commits:
commit a3e8bacbdb8d50ca5eb4917462cc9806be4879a2
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Feb 9 11:11:21 2022 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Feb 9 15:24:21 2022 +0100

    Flatten SvGlobalName::MakeId
    
    Change-Id: I5b592162d0fad3e57cfe9ad6d4b2252e7f7596d9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129709
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index 87bb46d50c2b..7784f3fc722a 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -100,63 +100,55 @@ void SvGlobalName::MakeFromMemory( void const * pData )
 bool SvGlobalName::MakeId( const OUString & rIdStr )
 {
     const sal_Unicode *pStr = rIdStr.getStr();
-    if( rIdStr.getLength() == 36
-      && '-' == pStr[ 8 ]  && '-' == pStr[ 13 ]
-      && '-' == pStr[ 18 ] && '-' == pStr[ 23 ] )
+    if( rIdStr.getLength() != 36
+      || '-' != pStr[ 8 ]  || '-' != pStr[ 13 ]
+      || '-' != pStr[ 18 ] || '-' != pStr[ 23 ] )
+        return false;
+
+    SvGUID aGuid = {};
+    auto asciiHexDigitToNumber = [](sal_Unicode c) -> sal_uInt8
     {
-        SvGUID aGuid = {};
-        auto asciiHexDigitToNumber = [](sal_Unicode c) -> sal_uInt8
-        {
-            if (rtl::isAsciiDigit(c))
-                return c - '0';
-            else
-                return rtl::toAsciiUpperCase(c) - 'A' + 10;
-        };
-        for( int i = 0; i < 8; i++ )
-        {
-            if( rtl::isAsciiHexDigit( *pStr ) )
-                aGuid.Data1 = aGuid.Data1 * 16 + asciiHexDigitToNumber( *pStr 
);
-            else
-                return false;
-            pStr++;
-        }
-
-        pStr++;
-        for( int i = 0; i < 4; i++ )
-        {
-            if( rtl::isAsciiHexDigit( *pStr ) )
-                aGuid.Data2 = aGuid.Data2 * 16 + asciiHexDigitToNumber( *pStr 
);
-            else
-                return false;
-            pStr++;
-        }
-
-        pStr++;
-        for( int i = 0; i < 4; i++ )
-        {
-            if( rtl::isAsciiHexDigit( *pStr ) )
-                aGuid.Data3 = aGuid.Data3 * 16 + asciiHexDigitToNumber( *pStr 
);
-            else
-                return false;
-            pStr++;
-        }
-
-        pStr++;
-        for( int i = 0; i < 16; i++ )
-        {
-            if( rtl::isAsciiHexDigit( *pStr ) )
-                aGuid.Data4[i/2] = aGuid.Data4[i/2] * 16 + 
asciiHexDigitToNumber( *pStr );
-            else
-                return false;
-            pStr++;
-            if( i == 3 )
-                pStr++;
-        }
+        if (rtl::isAsciiDigit(c))
+            return c - '0';
+        else
+            return rtl::toAsciiUpperCase(c) - 'A' + 10;
+    };
 
-        m_aData = aGuid;
-        return true;
+    for( int i = 0; i < 8; i++ )
+    {
+        if( !rtl::isAsciiHexDigit( *pStr ) )
+            return false;
+        aGuid.Data1 = aGuid.Data1 * 16 + asciiHexDigitToNumber( *pStr++ );
     }
-    return false;
+
+    pStr++;
+    for( int i = 0; i < 4; i++ )
+    {
+        if( !rtl::isAsciiHexDigit( *pStr ) )
+            return false;
+        aGuid.Data2 = aGuid.Data2 * 16 + asciiHexDigitToNumber( *pStr++ );
+    }
+
+    pStr++;
+    for( int i = 0; i < 4; i++ )
+    {
+        if( !rtl::isAsciiHexDigit( *pStr ) )
+            return false;
+        aGuid.Data3 = aGuid.Data3 * 16 + asciiHexDigitToNumber( *pStr++ );
+    }
+
+    pStr++;
+    for( int i = 0; i < 16; i++ )
+    {
+        if( !rtl::isAsciiHexDigit( *pStr ) )
+            return false;
+        aGuid.Data4[i/2] = aGuid.Data4[i/2] * 16 + asciiHexDigitToNumber( 
*pStr++ );
+        if( i == 3 )
+            pStr++;
+    }
+
+    m_aData = aGuid;
+    return true;
 }
 
 OUString SvGlobalName::GetHexName() const

Reply via email to