]> git.saurik.com Git - cydia.git/commitdiff
Reorganized and bit-packed fields of Package.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 1 Dec 2010 00:03:55 +0000 (16:03 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 1 Dec 2010 09:46:26 +0000 (01:46 -0800)
MobileCydia.mm

index dc0b738ae5486c9298be97f8677fc2a7aada4ae8..da729a8932903fe9ba0df296675aaa30614f84d0 100644 (file)
@@ -1826,34 +1826,35 @@ struct ParsedPackage {
 };
 
 @interface Package : NSObject {
-    unsigned era_;
+    uint32_t era_ : 29;
+    uint32_t essential_ : 1;
+    uint32_t obsolete_ : 1;
+    uint32_t ignored_ : 1;
+
     apr_pool_t *pool_;
 
+    _transient Database *database_;
+
     pkgCache::VerIterator version_;
     pkgCache::PkgIterator iterator_;
-    _transient Database *database_;
     pkgCache::VerFileIterator file_;
 
-    Source *source_;
-    ParsedPackage *parsed_;
-
-    CYString section_;
-    _transient NSString *section$_;
-    bool essential_;
-    bool obsolete_;
+    CYString id_;
+    CYString name_;
 
     CYString latest_;
     CYString installed_;
 
-    CYString id_;
-    CYString name_;
+    CYString section_;
+    _transient NSString *section$_;
 
-    NSMutableArray *tags_;
-    NSString *role_;
+    Source *source_;
 
     PackageValue *metadata_;
+    ParsedPackage *parsed_;
 
-    bool ignored_;
+    NSMutableArray *tags_;
+    NSString *role_;
 }
 
 - (Package *) initWithVersion:(pkgCache::VerIterator)version withZone:(NSZone *)zone inPool:(apr_pool_t *)pool database:(Database *)database;
@@ -2184,27 +2185,17 @@ struct PackageNameOrdering :
 - (Package *) initWithVersion:(pkgCache::VerIterator)version withZone:(NSZone *)zone inPool:(apr_pool_t *)pool database:(Database *)database {
     if ((self = [super init]) != nil) {
     _profile(Package$initWithVersion)
-        era_ = [database era];
         pool_ = pool;
 
-        version_ = version;
-
-        _profile(Package$initWithVersion$ParentPkg)
-            iterator_ = version.ParentPkg();
-        _end
-
         database_ = database;
+        era_ = [database era];
 
-        _profile(Package$initWithVersion$Latest)
-            latest_.set(NULL, StripVersion_(version_.VerStr()));
-        _end
+        version_ = version;
 
-        pkgCache::VerIterator current;
-        _profile(Package$initWithVersion$Versions)
-            current = iterator_.CurrentVer();
-            if (!current.end())
-                installed_.set(NULL, StripVersion_(current.VerStr()));
+        pkgCache::PkgIterator iterator(version.ParentPkg());
+        iterator_ = iterator;
 
+        _profile(Package$initWithVersion$Version)
             if (!version_.end())
                 file_ = version_.FileList();
             else {
@@ -2213,12 +2204,18 @@ struct PackageNameOrdering :
             }
         _end
 
-        _profile(Package$initWithVersion$Name)
-            id_.set(NULL, iterator_.Name());
-            name_.set(NULL, iterator_.Display());
+        _profile(Package$initWithVersion$Cache)
+            id_.set(NULL, iterator.Name());
+            name_.set(NULL, iterator.Display());
+
+            latest_.set(NULL, StripVersion_(version_.VerStr()));
+
+            pkgCache::VerIterator current(iterator.CurrentVer());
+            if (!current.end())
+                installed_.set(NULL, StripVersion_(current.VerStr()));
         _end
 
-        _profile(Package$initWithVersion$lowercaseString)
+        _profile(Package$initWithVersion$Lower)
             // XXX: do not use tolower() as this is not locale-specific? :(
             char *data(id_.data());
             for (size_t i(0), e(id_.size()); i != e; ++i)
@@ -2232,7 +2229,7 @@ struct PackageNameOrdering :
         _end
 
         _profile(Package$initWithVersion$Tags)
-            pkgCache::TagIterator tag(iterator_.TagList());
+            pkgCache::TagIterator tag(iterator.TagList());
             if (!tag.end()) {
                 tags_ = [[NSMutableArray alloc] initWithCapacity:8];
                 do {
@@ -2278,14 +2275,13 @@ struct PackageNameOrdering :
         _end
 
         _profile(Package$initWithVersion$Section)
-            section_.set(NULL, iterator_.Section());
+            section_.set(NULL, iterator.Section());
         _end
 
-        _profile(Package$initWithVersion$hasTag)
-            essential_ |= ((iterator_->Flags & pkgCache::Flag::Essential) == 0 ? NO : YES);
+        _profile(Package$initWithVersion$Flags)
+            essential_ |= ((iterator->Flags & pkgCache::Flag::Essential) == 0 ? NO : YES);
+            ignored_ = iterator->SelectedState == pkgCache::State::Hold;
         _end
-
-        ignored_ = iterator_->SelectedState == pkgCache::State::Hold;
     _end } return self;
 }