diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2009-01-22 06:02:46 +0000 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2010-09-30 07:09:39 +0000 |
commit | 76933519310a2b5ee1d6020b27d173316498adb6 (patch) | |
tree | 6ce79b863723f940d8b472644f58d05f2765e47a | |
parent | 0a3b45ef59725283581d5c70d843e4696d09a378 (diff) |
Welcome to unsafe optimizations.
-rw-r--r-- | Cydia.mm | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -129,6 +129,7 @@ class ProfileTime { private: const char *name_; uint64_t total_; + uint64_t count_; public: ProfileTime(const char *name) : @@ -140,12 +141,14 @@ class ProfileTime { void AddTime(uint64_t time) { total_ += time; + ++count_; } void Print() { if (total_ != 0) - std::cerr << std::setw(7) << total_ << " : " << name_ << std::endl; + std::cerr << std::setw(5) << count_ << ", " << std::setw(7) << total_ << " : " << name_ << std::endl; total_ = 0; + count_ = 0; } }; @@ -4375,6 +4378,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { /* Filtered Package Table {{{ */ @interface FilteredPackageTable : PackageTable { SEL filter_; + IMP imp_; id object_; } @@ -4402,7 +4406,9 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { } - (bool) hasPackage:(Package *)package { - return [package valid] && (*reinterpret_cast<bool (*)(id, SEL, id)>(&objc_msgSend))(package, filter_, object_); + _profile(FilteredPackageTable$hasPackage) + return [package valid] && (*reinterpret_cast<bool (*)(id, SEL, id)>(imp_))(package, filter_, object_); + _end } - (id) initWithBook:(RVBook *)book database:(Database *)database title:(NSString *)title filter:(SEL)filter with:(id)object { @@ -4410,6 +4416,11 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { filter_ = filter; object_ = object == nil ? nil : [object retain]; + /* XXX: this is an unsafe optimization of doomy hell */ + Method method = class_getInstanceMethod([Package class], filter); + imp_ = method_getImplementation(method); + _assert(imp_ != NULL); + [self reloadData]; } return self; } |