From 8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 25 Apr 2012 02:26:22 +0300 Subject: Improve iterators part 1. --- src/gui/shopwindow.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/gui/shopwindow.cpp') diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index fccb953b6..615bbc18b 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -408,8 +408,8 @@ void ShopWindow::saveList() } std::vector items = mBuyShopItems->items(); - std::vector::const_iterator it; - for (it = items.begin(); it != items.end(); ++it) + for (std::vector::const_iterator it = items.begin(), + it_end = items.end(); it != it_end; ++it) { ShopItem *item = *(it); if (item) @@ -417,7 +417,8 @@ void ShopWindow::saveList() } items = mSellShopItems->items(); - for (it = items.begin(); it != items.end(); ++it) + for (std::vector::const_iterator it = items.begin(), + it_end = items.end(); it != it_end; ++it) { if (!(*it)) continue; @@ -440,8 +441,8 @@ void ShopWindow::saveList() sellItem->getPrice()) << std::endl; } - std::map::const_iterator mapIt; - for (mapIt = mapItems.begin(); mapIt != mapItems.end(); ++mapIt) + for (std::map::const_iterator mapIt = mapItems.begin(), + mapIt_end = mapItems.end(); mapIt != mapIt_end; ++mapIt) { ShopItem *buyItem = (*mapIt).second; if (buyItem) @@ -480,9 +481,9 @@ void ShopWindow::announce(ShopItems *list, int mode) mSellAnnounceButton->setEnabled(false); std::vector items = list->items(); - std::vector::const_iterator it; - for (it = items.begin(); it != items.end(); ++it) + for (std::vector::const_iterator it = items.begin(), + it_end = items.end(); it != it_end; ++it) { ShopItem *item = *(it); if (item->getQuantity() > 1) @@ -546,9 +547,9 @@ void ShopWindow::giveList(const std::string &nick, int mode) return; std::vector items = list->items(); - std::vector::const_iterator it; - for (it = items.begin(); it != items.end(); ++it) + for (std::vector::const_iterator it = items.begin(), + it_end = items.end(); it != it_end; ++it) { ShopItem *item = *(it); if (!item) @@ -792,7 +793,6 @@ bool ShopWindow::findShopItem(ShopItem *shopItem, int mode) return false; std::vector items; - std::vector::const_iterator it; if (mode == SELL) { if (!mSellShopItems) @@ -806,7 +806,8 @@ bool ShopWindow::findShopItem(ShopItem *shopItem, int mode) items = mBuyShopItems->items(); } - for (it = items.begin(); it != items.end(); ++it) + for (std::vector::const_iterator it = items.begin(), + it_end = items.end(); it != it_end; ++ it) { ShopItem *item = *(it); if (!item) -- cgit v1.2.3-60-g2f50