* apt-pkg/depcache.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 3 Jun 2010 08:45:58 +0000 (10:45 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 3 Jun 2010 08:45:58 +0000 (10:45 +0200)
  - switch i{Download,Usr}Size from double to (un)signed long long

The biggest reason is that this saves a lot of float point operations
we do in AddSizes() on integers. The only reason i see that this was
a double is that it was 64bit long and can therefore store bigger
values than int/long, but with the availablity of (un)signed long long
we are now also at 64bit and can store sizes more than 8 Exabytes big -
by the time this will be a limit the C/C++ Standard will have bigger types,
hopefully.

apt-pkg/acquire.cc
apt-pkg/acquire.h
apt-pkg/depcache.h
debian/changelog

index 832eaa0..63825da 100644 (file)
@@ -506,9 +506,9 @@ bool pkgAcquire::Clean(string Dir)
 // Acquire::TotalNeeded - Number of bytes to fetch                     /*{{{*/
 // ---------------------------------------------------------------------
 /* This is the total number of bytes needed */
-double pkgAcquire::TotalNeeded()
+unsigned long long pkgAcquire::TotalNeeded()
 {
-   double Total = 0;
+   unsigned long long Total = 0;
    for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); I++)
       Total += (*I)->FileSize;
    return Total;
@@ -517,9 +517,9 @@ double pkgAcquire::TotalNeeded()
 // Acquire::FetchNeeded - Number of bytes needed to get                        /*{{{*/
 // ---------------------------------------------------------------------
 /* This is the number of bytes that is not local */
-double pkgAcquire::FetchNeeded()
+unsigned long long pkgAcquire::FetchNeeded()
 {
-   double Total = 0;
+   unsigned long long Total = 0;
    for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); I++)
       if ((*I)->Local == false)
         Total += (*I)->FileSize;
@@ -529,9 +529,9 @@ double pkgAcquire::FetchNeeded()
 // Acquire::PartialPresent - Number of partial bytes we already have   /*{{{*/
 // ---------------------------------------------------------------------
 /* This is the number of bytes that is not local */
-double pkgAcquire::PartialPresent()
+unsigned long long pkgAcquire::PartialPresent()
 {
-  double Total = 0;
+  unsigned long long Total = 0;
    for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); I++)
       if ((*I)->Local == false)
         Total += (*I)->PartialSize;
index 8e2c211..82be8b8 100644 (file)
@@ -323,17 +323,17 @@ class pkgAcquire
    /** \return the total size in bytes of all the items included in
     *  this download.
     */
-   double TotalNeeded();
+   unsigned long long TotalNeeded();
 
    /** \return the size in bytes of all non-local items included in
     *  this download.
     */
-   double FetchNeeded();
+   unsigned long long FetchNeeded();
 
    /** \return the amount of data to be fetched that is already
     *  present on the filesystem.
     */
-   double PartialPresent();
+   unsigned long long PartialPresent();
 
    /** \brief Delayed constructor
     *
index d425843..c6f245a 100644 (file)
@@ -286,9 +286,11 @@ class pkgDepCache : protected pkgCache::Namespace
    pkgCache *Cache;
    StateCache *PkgState;
    unsigned char *DepState;
-   
-   double iUsrSize;
-   double iDownloadSize;
+
+   /** Stores the space changes after installation */
+   signed long long iUsrSize;
+   /** Stores how much we need to download to get the packages */
+   unsigned long long iDownloadSize;
    unsigned long iInstCount;
    unsigned long iDelCount;
    unsigned long iKeepCount;
@@ -452,8 +454,8 @@ class pkgDepCache : protected pkgCache::Namespace
    bool writeStateFile(OpProgress *prog, bool InstalledOnly=true);
    
    // Size queries
-   inline double UsrSize() {return iUsrSize;};
-   inline double DebSize() {return iDownloadSize;};
+   inline signed long long UsrSize() {return iUsrSize;};
+   inline unsigned long long DebSize() {return iDownloadSize;};
    inline unsigned long DelCount() {return iDelCount;};
    inline unsigned long KeepCount() {return iKeepCount;};
    inline unsigned long InstCount() {return iInstCount;};
index 2be9567..97d6abe 100644 (file)
@@ -7,6 +7,7 @@ apt (0.7.26~exp6) UNRELEASED; urgency=low
     - deal with long long, not with int to remove 2GB Limit (LP: #250909)
     - deprecate AddSize with Multiplier as it is unused and switch to
       boolean instead to handle the sizes more gracefully.
+    - switch i{Download,Usr}Size from double to (un)signed long long
 
  -- David Kalnischkies <kalnischkies@gmail.com>  Thu, 03 Jun 2010 09:19:01 +0200