sc/source/core/tool/interpr4.cxx |   23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

New commits:
commit 196806fe04963bc83dbae9134e0158361322247f
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Feb 5 11:48:56 2025 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sat Feb 15 11:15:42 2025 +0100

    Deduplicate ScInterpreter::GetStackType
    
    Avoid code duplication.
    
    Change-Id: I48bb3b00568e80f2de5b9fe632ed9c2db341c9cc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181692
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index b95fba94a6ed..28a36b0332df 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1966,34 +1966,27 @@ bool ScInterpreter::IsMissing() const
 
 StackVar ScInterpreter::GetRawStackType()
 {
-    StackVar eRes;
     if( sp )
     {
-        eRes = pStack[sp - 1]->GetType();
+        return pStack[sp - 1]->GetType();
     }
     else
     {
         SetError(FormulaError::UnknownStackVariable);
-        eRes = svUnknown;
+        return svUnknown;
     }
-    return eRes;
 }
 
 StackVar ScInterpreter::GetStackType()
 {
-    StackVar eRes;
-    if( sp )
-    {
-        eRes = pStack[sp - 1]->GetType();
-        if( eRes == svMissing || eRes == svEmptyCell )
-            eRes = svDouble;    // default!
-    }
-    else
+    switch (StackVar eRes = GetRawStackType())
     {
-        SetError(FormulaError::UnknownStackVariable);
-        eRes = svUnknown;
+        case svMissing:
+        case svEmptyCell:
+            return svDouble; // default!
+        default:
+            return eRes;
     }
-    return eRes;
 }
 
 StackVar ScInterpreter::GetStackType( sal_uInt8 nParam )

Reply via email to