[PATCH] Reuse ImplPower10()

Christina Roßmanith (via_Code_Review) gerrit at gerrit.libreoffice.org
Sat Mar 16 13:03:25 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2774

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/74/2774/1

Reuse ImplPower10()

Change-Id: I0a86e43065689d2478ced4804ab083244d8d35f5
---
M vcl/source/control/field.cxx
1 file changed, 5 insertions(+), 19 deletions(-)



diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index c0037e9..69cb02e 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -53,7 +53,7 @@
 
 static sal_Int64 ImplPower10( sal_uInt16 n )
 {
-    sal_uInt16 i;
+    sal_uInt16  i;
     sal_Int64   nValue = 1;
 
     for ( i=0; i < n; i++ )
@@ -1264,9 +1264,7 @@
         {
             if ( (mnBaseValue <= 0) || (nValue <= 0) )
                 return nValue;
-            nDiv = 100;
-            for ( sal_uInt16 i=0; i < nDecDigits; i++ )
-                nDiv *= 10;
+            nDiv = 100 * ImplPower10(nDecDigits);
 
             nMult = mnBaseValue;
         }
@@ -1333,11 +1331,7 @@
     }
     else
     {
-        while ( nDecDigits )
-        {
-            nValue *= 10;
-            nDecDigits--;
-        }
+        nValue *= ImplPower10(nDecDigits);
     }
 
     if ( eFieldUnit != eOutUnit )
@@ -1381,19 +1375,11 @@
 
     if ( nDecDigits < 0 )
     {
-        while ( nDecDigits )
-        {
-            nValue *= 10;
-            nDecDigits++;
-        }
+        nValue *= ImplPower10(-nDecDigits);
     }
     else
     {
-        while ( nDecDigits )
-        {
-            nValue /= 10;
-            nDecDigits--;
-        }
+        nValue /= ImplPower10(nDecDigits);
     }
 
     if ( eFieldUnit != eInUnit )

-- 
To view, visit https://gerrit.libreoffice.org/2774
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a86e43065689d2478ced4804ab083244d8d35f5
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Christina Roßmanith <ChrRossmanith at web.de>



More information about the LibreOffice mailing list