From a5d9833346499aadc1c200f9d77f87a4ad148ceb Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 22 Sep 2013 17:26:55 -0400 Subject: [PATCH] HaikuDepot: Minor optimization. - PackageAction now stores/returns a type code indicating the embodied action. Adjust PackageActionView accordingly in its comparison of the old/new package action list. --- src/apps/haiku-depot/PackageAction.cpp | 5 +++-- src/apps/haiku-depot/PackageAction.h | 13 ++++++++++++- src/apps/haiku-depot/PackageInfoView.cpp | 4 ++-- src/apps/haiku-depot/PackageManager.cpp | 4 ++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/apps/haiku-depot/PackageAction.cpp b/src/apps/haiku-depot/PackageAction.cpp index d6d8715e96..e4697aa90c 100644 --- a/src/apps/haiku-depot/PackageAction.cpp +++ b/src/apps/haiku-depot/PackageAction.cpp @@ -16,9 +16,10 @@ using namespace BPackageKit; // #pragma mark - PackageAction -PackageAction::PackageAction(PackageInfoRef package) +PackageAction::PackageAction(int32 type, PackageInfoRef package) : - fPackage(package) + fPackage(package), + fType(type) { // TODO: allow configuring the installation location fPackageManager = new(std::nothrow) PackageManager( diff --git a/src/apps/haiku-depot/PackageAction.h b/src/apps/haiku-depot/PackageAction.h index 54a2555351..7f9ed8d045 100644 --- a/src/apps/haiku-depot/PackageAction.h +++ b/src/apps/haiku-depot/PackageAction.h @@ -14,12 +14,22 @@ class PackageManager; +enum { + PACKAGE_ACTION_INSTALL = 0, + PACKAGE_ACTION_UNINSTALL, + PACKAGE_ACTION_MAX +}; + class PackageAction : public BReferenceable { public: - PackageAction(PackageInfoRef package); + PackageAction(int32 type, + PackageInfoRef package); virtual ~PackageAction(); + int32 Type() const + { return fType; } + virtual const char* Label() const = 0; virtual status_t Perform() = 0; @@ -32,6 +42,7 @@ protected: private: PackageInfoRef fPackage; + int32 fType; }; diff --git a/src/apps/haiku-depot/PackageInfoView.cpp b/src/apps/haiku-depot/PackageInfoView.cpp index 75c6a96b78..fe416907e0 100644 --- a/src/apps/haiku-depot/PackageInfoView.cpp +++ b/src/apps/haiku-depot/PackageInfoView.cpp @@ -547,8 +547,8 @@ public: clearNeeded = true; else { for (int32 i = 0; i < actions.CountItems(); i++) { - if (strcasecmp(actions.ItemAtFast(i)->Label(), - fPackageActions.ItemAtFast(i)->Label()) != 0) { + if (actions.ItemAtFast(i)->Type() + != fPackageActions.ItemAtFast(i)->Type()) { clearNeeded = true; break; } diff --git a/src/apps/haiku-depot/PackageManager.cpp b/src/apps/haiku-depot/PackageManager.cpp index e5fc264149..4dcd91a090 100644 --- a/src/apps/haiku-depot/PackageManager.cpp +++ b/src/apps/haiku-depot/PackageManager.cpp @@ -50,7 +50,7 @@ class InstallPackageAction : public PackageAction { public: InstallPackageAction(PackageInfoRef package) : - PackageAction(package) + PackageAction(PACKAGE_ACTION_INSTALL, package) { } @@ -98,7 +98,7 @@ class UninstallPackageAction : public PackageAction { public: UninstallPackageAction(PackageInfoRef package) : - PackageAction(package) + PackageAction(PACKAGE_ACTION_UNINSTALL, package) { }