summaryrefslogtreecommitdiff
path: root/Cydia.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2009-04-19 07:19:17 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2010-09-30 07:13:12 +0000
commit188763870ad2df5c626d4837181ee64ba1b8c3e2 (patch)
treeaa225110d1733051f5a35587894e2495165cb414 /Cydia.mm
parentb1ce61ecebc8b20d0cf4a71efb3392680faede53 (diff)
Further performance improvements.
Diffstat (limited to 'Cydia.mm')
-rw-r--r--Cydia.mm118
1 files changed, 44 insertions, 74 deletions
diff --git a/Cydia.mm b/Cydia.mm
index 2784d00..3a410e0 100644
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -1023,6 +1023,13 @@ NSString *SizeString(double size) {
return [NSString stringWithFormat:@"%s%.1f %s", (negative ? "-" : ""), size, powers_[power]];
}
+NSString *StripVersion(const char *version) {
+ const char *colon(strchr(version, ':'));
+ if (colon != NULL)
+ version = colon + 1;
+ return [NSString stringWithUTF8String:version];
+}
+
NSString *StripVersion(NSString *version) {
NSRange colon = [version rangeOfString:@":"];
if (colon.location != NSNotFound)
@@ -1748,29 +1755,19 @@ uint32_t PackageChangesRadix(Package *self, void *) {
database_ = database;
_profile(Package$initWithVersion$Latest)
- latest_ = [StripVersion([NSString stringWithUTF8String:version_.VerStr()]) retain];
- _end
-
- pkgCache::VerIterator current;
- NSString *installed;
-
- _profile(Package$initWithVersion$Current)
- current = iterator_.CurrentVer();
- installed = current.end() ? nil : [NSString stringWithUTF8String:current.VerStr()];
+ latest_ = [StripVersion(version_.VerStr()) retain];
_end
- _profile(Package$initWithVersion$Installed)
- installed_ = [StripVersion(installed) retain];
- _end
+ pkgCache::VerIterator current(iterator_.CurrentVer());
+ if (!current.end())
+ installed_ = [StripVersion(current.VerStr()) retain];
- _profile(Package$initWithVersion$File)
- if (!version_.end())
- file_ = version_.FileList();
- else {
- pkgCache &cache([database_ cache]);
- file_ = pkgCache::VerFileIterator(cache, cache.VerFileP);
- }
- _end
+ if (!version_.end())
+ file_ = version_.FileList();
+ else {
+ pkgCache &cache([database_ cache]);
+ file_ = pkgCache::VerFileIterator(cache, cache.VerFileP);
+ }
_profile(Package$initWithVersion$Name)
id_ = [[NSString stringWithUTF8String:iterator_.Name()] retain];
@@ -1789,63 +1786,36 @@ uint32_t PackageChangesRadix(Package *self, void *) {
parser = &[database_ records]->Lookup(file_);
_end
- const char *begin, *end;
- parser->GetRec(begin, end);
-
CYString website;
CYString tag;
- struct {
- const char *name_;
- CYString *value_;
- } names[] = {
- {"name", &name_},
- {"icon", &icon_},
- {"depiction", &depiction_},
- {"homepage", &homepage_},
- {"website", &website},
- {"support", &support_},
- {"sponsor", &sponsor_},
- {"author", &author_},
- {"tag", &tag},
- };
-
- while (begin != end)
- if (*begin == '\n') {
- ++begin;
- continue;
- } else if (isblank(*begin)) next: {
- begin = static_cast<char *>(memchr(begin + 1, '\n', end - begin - 1));
- if (begin == NULL)
- break;
- } else if (const char *colon = static_cast<char *>(memchr(begin, ':', end - begin))) {
- const char *name(begin);
- size_t size(colon - begin);
-
- begin = static_cast<char *>(memchr(begin, '\n', end - begin));
-
- {
- const char *stop(begin == NULL ? end : begin);
- while (stop[-1] == '\r')
- --stop;
- while (++colon != stop && isblank(*colon));
-
- for (size_t i(0); i != sizeof(names) / sizeof(names[0]); ++i)
- if (strncasecmp(names[i].name_, name, size) == 0) {
- CYString &value(*names[i].value_);
-
- _profile(Package$initWithVersion$Parse$Value)
- value.set(pool, colon, stop - colon);
- _end
-
- break;
- }
+ _profile(Package$initWithVersion$Parse$Find)
+ struct {
+ const char *name_;
+ CYString *value_;
+ } names[] = {
+ {"name", &name_},
+ {"icon", &icon_},
+ {"depiction", &depiction_},
+ {"homepage", &homepage_},
+ {"website", &website},
+ {"support", &support_},
+ {"sponsor", &sponsor_},
+ {"author", &author_},
+ {"tag", &tag},
+ };
+
+ for (size_t i(0); i != sizeof(names) / sizeof(names[0]); ++i) {
+ const char *start, *end;
+
+ if (parser->Find(names[i].name_, start, end)) {
+ CYString &value(*names[i].value_);
+ _profile(Package$initWithVersion$Parse$Value)
+ value.set(pool, start, end - start);
+ _end
}
-
- if (begin == NULL)
- break;
- ++begin;
- } else goto next;
+ }
+ _end
_profile(Package$initWithVersion$Parse$Tagline)
tagline_.set(pool, parser->ShortDesc());
@@ -7920,7 +7890,7 @@ int main(int argc, char *argv[]) { _pooled
Locale_ = CFLocaleCopyCurrent();
Languages_ = [NSLocale preferredLanguages];
//CFStringRef locale(CFLocaleGetIdentifier(Locale_));
- NSLog(@"%@", [Languages_ description]);
+ //NSLog(@"%@", [Languages_ description]);
const char *lang;
if (Languages_ == nil || [Languages_ count] == 0)
lang = NULL;