From 5e8f4256fedbb33eaed7766843a5074a8b518470 Mon Sep 17 00:00:00 2001 From: Adrien Destugues - PulkoMandy Date: Sat, 3 Mar 2012 22:44:35 +0100 Subject: [PATCH] Revert part of r43092. * Caching of CountItems() to avoid calling it at each loop iteration * Use of strcasecmp when comparing strings for exact equality --- src/apps/deskbar/ExpandoMenuBar.cpp | 2 +- src/apps/deskbar/WindowMenu.cpp | 9 +++++++-- src/apps/deskbar/WindowMenuItem.cpp | 9 ++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 5d3a479415..317cffeac0 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -787,7 +787,7 @@ TExpandoMenuBar::monitor_team_windows(void* arg) ((1 << current_workspace()) & wInfo->workspaces) != 0); - if (strcasecmp(wInfo->name, + if (strcmp(wInfo->name, item->FullTitle()) != 0) item->SetLabel(wInfo->name); diff --git a/src/apps/deskbar/WindowMenu.cpp b/src/apps/deskbar/WindowMenu.cpp index 6910ecd4aa..0e2cf2d936 100644 --- a/src/apps/deskbar/WindowMenu.cpp +++ b/src/apps/deskbar/WindowMenu.cpp @@ -116,7 +116,8 @@ TWindowMenu::AttachedToWindow() int32 parentMenuItems = 0; - for (int32 i = 0; i < fTeam->CountItems(); i++) { + int32 teamCount = fTeam->CountItems(); + for (int32 i = 0; i < teamCount; i++) { team_id theTeam = (team_id)fTeam->ItemAt(i); int32 tokenCount = 0; int32* tokens = get_token_list(theTeam, &tokenCount); @@ -130,7 +131,11 @@ TWindowMenu::AttachedToWindow() && (wInfo->show_hide_level <= 0 || wInfo->is_mini)) { // Don't add new items if we're expanded. We've already done // this, they've just been moved. - for (int32 addIndex = 0; addIndex < CountItems(); addIndex++) { + int32 numItems = CountItems(); + + // Find first item that sorts alphabetically after this window, + // so we know where to put it + for (int32 addIndex = 0; addIndex < numItems; addIndex++) { TWindowMenuItem* item = static_cast(ItemAt(addIndex)); if (item != NULL diff --git a/src/apps/deskbar/WindowMenuItem.cpp b/src/apps/deskbar/WindowMenuItem.cpp index 61e0ad0e03..70469cdbf9 100644 --- a/src/apps/deskbar/WindowMenuItem.cpp +++ b/src/apps/deskbar/WindowMenuItem.cpp @@ -133,7 +133,7 @@ TWindowMenuItem::SetLabel(const char* string) Frame().Width() - contLoc.x - 3.0f); } - if (strcasecmp(Label(), truncatedTitle.String()) != 0) + if (strcmp(Label(), truncatedTitle.String()) != 0) BMenuItem::SetLabel(truncatedTitle.String()); } @@ -149,18 +149,13 @@ TWindowMenuItem::FullTitle() const TWindowMenuItem::InsertIndexFor(BMenu* menu, int32 startIndex, TWindowMenuItem* newItem) { - int32 index = 0; - - for (index = startIndex;; index++) { + for (int32 index = startIndex;; index++) { TWindowMenuItem* item = dynamic_cast(menu->ItemAt(index)); if (item == NULL || NaturalCompare(item->FullTitle(), newItem->FullTitle()) > 0) return index; } - - // we should never get here - return index; }