diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2010-12-06 04:58:20 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2011-01-01 14:32:05 -0800 |
commit | fe33a23ef38f596b2a71ccdf16876cf8d460a68a (patch) | |
tree | ce9b7335347a929170dc6ba880092c213a5c4243 /MobileCydia.mm | |
parent | df30fbeeffdde520154ea445b7ac9ff2c99ce198 (diff) |
Cache section remap using APT cache pointer.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r-- | MobileCydia.mm | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index 18fbe49..6e2b190 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -1355,6 +1355,8 @@ typedef std::map< unsigned long, _H<Source> > SourceMap; int cydiafd_; int statusfd_; FILE *input_; + + std::map<const char *, _H<NSString> > sections_; } + (Database *) sharedInstance; @@ -1388,6 +1390,9 @@ typedef std::map< unsigned long, _H<Source> > SourceMap; - (void) setDelegate:(id)delegate; - (Source *) getSource:(pkgCache::PkgFileIterator)file; + +- (NSString *) mappedSectionForPointer:(const char *)pointer; + @end /* }}} */ /* Delegate Helpers {{{ */ @@ -1844,7 +1849,7 @@ struct ParsedPackage { CYString latest_; CYString installed_; - CYString section_; + const char *section_; _transient NSString *section$_; Source *source_; @@ -2267,7 +2272,7 @@ struct PackageNameOrdering : _end _profile(Package$initWithVersion$Section) - section_.set(NULL, iterator.Section()); + section_ = iterator.Section(); _end _profile(Package$initWithVersion$Flags) @@ -2315,13 +2320,11 @@ struct PackageNameOrdering : - (NSString *) section { if (section$_ == nil) { - if (section_.empty()) + if (section_ == NULL) return nil; - _profile(Package$section) - std::replace(section_.data(), section_.data() + section_.size(), '_', ' '); - NSString *name(section_); - section$_ = [SectionMap_ objectForKey:name] ?: name; + _profile(Package$section$mappedSectionForPointer) + section$_ = [database_ mappedSectionForPointer:section_]; _end } return section$_; } @@ -2487,7 +2490,11 @@ struct PackageNameOrdering : if (![self unfiltered]) return false; - NSString *section([self section]); + NSString *section; + + _profile(Package$visible$section) + section = [self section]; + _end _profile(Package$visible$isSectionVisible) if (section != nil && !isSectionVisible(section)) @@ -3677,6 +3684,31 @@ static NSString *Warning_; return i == sources_.end() ? nil : i->second; } +- (NSString *) mappedSectionForPointer:(const char *)section { + _H<NSString> &mapped(sections_[section]); + + if (mapped == NULL) { + size_t length(strlen(section)); + char spaced[length + 1]; + + _profile(Database$mappedSectionForPointer$Replace) + for (size_t index(0); index != length; ++index) + spaced[index] = section[index] == '_' ? ' ' : section[index]; + spaced[length] = '\0'; + _end + + NSString *string; + + _profile(Database$mappedSectionForPointer$stringWithUTF8String) + string = [NSString stringWithUTF8String:spaced]; + _end + + _profile(Database$mappedSectionForPointer$Map) + mapped = [SectionMap_ objectForKey:string] ?: string; + _end + } return mapped; +} + @end /* }}} */ |