From 7b41e8f17a60047b5424dc2dc5e181e0925b6159 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 30 Nov 2010 04:55:31 -0800 Subject: [PATCH 1/1] Don't copy strings from APT when you can point to them. --- MobileCydia.mm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/MobileCydia.mm b/MobileCydia.mm index bea252e5..ae9f0aad 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -772,10 +772,16 @@ class CYString { else { clear_(); - char *temp(reinterpret_cast(apr_palloc(pool, size + 1))); - memcpy(temp, data, size); - temp[size] = '\0'; - data_ = temp; + if (pool == NULL) + data_ = const_cast(data); + else { + char *temp(reinterpret_cast(apr_palloc(pool, size + 1))); + memcpy(temp, data, size); + temp[size] = '\0'; + + data_ = temp; + } + size_ = size; } } @@ -2194,14 +2200,14 @@ struct PackageNameOrdering : database_ = database; _profile(Package$initWithVersion$Latest) - latest_.set(pool_, StripVersion_(version_.VerStr())); + latest_.set(NULL, StripVersion_(version_.VerStr())); _end pkgCache::VerIterator current; _profile(Package$initWithVersion$Versions) current = iterator_.CurrentVer(); if (!current.end()) - installed_.set(pool_, StripVersion_(current.VerStr())); + installed_.set(NULL, StripVersion_(current.VerStr())); if (!version_.end()) file_ = version_.FileList(); @@ -2213,7 +2219,7 @@ struct PackageNameOrdering : _profile(Package$initWithVersion$Name) id_.set(pool_, iterator_.Name()); - name_.set(pool, iterator_.Display()); + name_.set(NULL, iterator_.Display()); _end _profile(Package$initWithVersion$lowercaseString) @@ -2260,7 +2266,7 @@ struct PackageNameOrdering : _end _profile(Package$initWithVersion$Section) - section_.set(pool_, iterator_.Section()); + section_.set(NULL, iterator_.Section()); _end _profile(Package$initWithVersion$hasTag) -- 2.45.2