[Libreoffice-commits] core.git: include/tools

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 6 09:45:14 UTC 2021


 include/tools/bigint.hxx |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 9b36cae4ca95ab9508752f2a13a45d09c3dbd87f
Author:     Noel Grandin <noel at peralex.com>
AuthorDate: Wed Jan 6 10:29:07 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jan 6 10:44:34 2021 +0100

    use anonymous union for BigInt
    
    since we only use one or the other of these fields.
    
    Change-Id: Ib9cb4895028420a74d0a65d6cd934b0f56f203a3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108833
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx
index a8d8575fb53b..53f681609ecf 100644
--- a/include/tools/bigint.hxx
+++ b/include/tools/bigint.hxx
@@ -28,8 +28,11 @@
 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC BigInt
 {
 private:
-    sal_Int32       nVal;
-    sal_uInt16      nNum[MAX_DIGITS];
+    // we only use one of these two fields at a time
+    union {
+        sal_Int32       nVal;
+        sal_uInt16      nNum[MAX_DIGITS];
+    };
     sal_uInt8       nLen        : 5;    // current length
     bool            bIsNeg      : 1,    // Is Sign negative?
                     bIsBig      : 1;    // if true , value is in nNum array


More information about the Libreoffice-commits mailing list