From 5ae8bdf49db36b2691ce545e3285f9ee64f92148 Mon Sep 17 00:00:00 2001
From: Ryan Pavlik <rpavlik@iastate.edu>
Date: Wed, 2 Nov 2011 13:33:38 -0400
Subject: Pre-increment non-primitive types.

Found with cppcheck:
"Prefix ++/-- operators should be preferred for non-primitive
types. Pre-increment/decrement can be more efficient than
post-increment/decrement. Post-increment/decrement usually
involves keeping a copy of the previous value around and adds
a little extra code."
---
 src/FbCommands.cc        |  4 ++--
 src/FbTk/Font.cc         |  4 ++--
 src/FbTk/ImageImlib2.cc  |  2 +-
 src/FbTk/Menu.cc         |  2 +-
 src/FbTk/STLUtil.hh      |  2 +-
 src/FbTk/Timer.cc        |  2 +-
 src/FbTk/TypeAhead.hh    |  6 +++---
 src/FocusableList.cc     |  2 +-
 src/Keys.cc              |  2 +-
 src/Remember.cc          |  8 ++++----
 src/Screen.cc            |  4 ++--
 src/Slit.cc              |  4 ++--
 src/Window.cc            |  4 ++--
 src/WorkspaceCmd.cc      | 10 +++++-----
 src/WorkspaceNameTool.cc |  4 ++--
 src/fluxbox.cc           | 12 ++++++------
 16 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index 63aa79d..b0289b8 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -512,7 +512,7 @@ void DeiconifyCmd::execute() {
 
     case ALL:
     case ALLWORKSPACE:
-        for(; it != itend; it++) {
+        for(; it != itend; ++it) {
             old_workspace_num= (*it)->workspaceNumber();
             if (m_mode == ALL || old_workspace_num == workspace_num ||
                 (*it)->isStuck()) {
@@ -526,7 +526,7 @@ void DeiconifyCmd::execute() {
     case LAST:
     case LASTWORKSPACE:
     default:
-        for (; it != itend; it++) {
+        for (; it != itend; ++it) {
             old_workspace_num= (*it)->workspaceNumber();
             if(m_mode == LAST || old_workspace_num == workspace_num ||
                (*it)->isStuck()) {
diff --git a/src/FbTk/Font.cc b/src/FbTk/Font.cc
index f06e6f6..37621a8 100644
--- a/src/FbTk/Font.cc
+++ b/src/FbTk/Font.cc
@@ -117,7 +117,7 @@ void Font::shutdown() {
         FontImp* font = fit->second;
         if (font) {
             FontCacheIt it;
-            for (it = fit; it != font_cache.end(); it++)
+            for (it = fit; it != font_cache.end(); ++it)
                 if (it->second == font)
                     it->second = 0;
             delete font;
@@ -181,7 +181,7 @@ bool Font::load(const string &name) {
     FbTk::StringUtil::stringtok<StringList>(names, name, "|");
 
     StringListIt name_it;
-    for (name_it = names.begin(); name_it != names.end(); name_it++) {
+    for (name_it = names.begin(); name_it != names.end(); ++name_it) {
         FbTk::StringUtil::removeTrailingWhitespace(*name_it);
         FbTk::StringUtil::removeFirstWhitespace(*name_it);
 
diff --git a/src/FbTk/ImageImlib2.cc b/src/FbTk/ImageImlib2.cc
index 21202a1..af103bd 100644
--- a/src/FbTk/ImageImlib2.cc
+++ b/src/FbTk/ImageImlib2.cc
@@ -36,7 +36,7 @@ public:
 
         std::map<int, Imlib_Context>::iterator it = this->begin();
         std::map<int, Imlib_Context>::iterator it_end = this->end();
-        for (; it != it_end; it++) {
+        for (; it != it_end; ++it) {
             imlib_context_free(it->second);
         }
 
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index 40f81c8..671d32a 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -1361,7 +1361,7 @@ void Menu::resetTypeAhead() {
     m_type_ahead.reset();
     m_matches.clear();
 
-    for (; it != vec.end(); it++)
+    for (; it != vec.end(); ++it)
         clearItem((*it)->getIndex(), true, 1);
 }
 
diff --git a/src/FbTk/STLUtil.hh b/src/FbTk/STLUtil.hh
index b1007f7..abc5472 100644
--- a/src/FbTk/STLUtil.hh
+++ b/src/FbTk/STLUtil.hh
@@ -85,7 +85,7 @@ F forAllIf(C& c, I i, F f) {
     typedef typename C::iterator iterator;
     iterator it = c.begin();
     iterator end = c.end();
-    for (; it != end; it++) {
+    for (; it != end; ++it) {
         if (i(*it))
             f(*it);
     }
diff --git a/src/FbTk/Timer.cc b/src/FbTk/Timer.cc
index f34db08..8b144db 100644
--- a/src/FbTk/Timer.cc
+++ b/src/FbTk/Timer.cc
@@ -189,7 +189,7 @@ void Timer::updateTimers(int fd) {
 
         time_t delta = last_time - now.tv_sec;
 
-        for (it = m_timerlist.begin(); it != m_timerlist.end(); it++) {
+        for (it = m_timerlist.begin(); it != m_timerlist.end(); ++it) {
             (*it)->m_start.tv_sec -= delta;
         }
     }
diff --git a/src/FbTk/TypeAhead.hh b/src/FbTk/TypeAhead.hh
index cac90a5..289587a 100644
--- a/src/FbTk/TypeAhead.hh
+++ b/src/FbTk/TypeAhead.hh
@@ -113,7 +113,7 @@ private:
     Items const *m_ref; // reference to vector we are operating on
 
     void fillValues(BaseItems const &search, Items &fillin) const {
-        for (BaseItemscIt it = search.begin(); it != search.end(); it++) {
+        for (BaseItemscIt it = search.begin(); it != search.end(); ++it) {
             Item_Type tmp = dynamic_cast<Item_Type>(*it);
             if (tmp)
                 fillin.push_back(tmp);
@@ -153,7 +153,7 @@ private:
     // iteration based on original list of items
     void doSearch(char to_test, Items const &items,
                   SearchResult &mySearchResult) const {
-        for (ItemscIt it = items.begin(); it != items.end(); it++) {
+        for (ItemscIt it = items.begin(); it != items.end(); ++it) {
             if ((*it)->iTypeCompareChar(to_test, stringSize()) && (*it)->isEnabled())
                 mySearchResult.add(*it);
         }
@@ -162,7 +162,7 @@ private:
     // iteration based on last SearchResult
     void doSearch(char to_test, BaseItems const &search,
                   SearchResult &mySearchResult) const {
-        for (BaseItemscIt it = search.begin(); it != search.end(); it++) {
+        for (BaseItemscIt it = search.begin(); it != search.end(); ++it) {
             if ((*it)->iTypeCompareChar(to_test, stringSize()) && (*it)->isEnabled())
                 mySearchResult.add(*it);
         }
diff --git a/src/FocusableList.cc b/src/FocusableList.cc
index 382a6f5..87c5bcc 100644
--- a/src/FocusableList.cc
+++ b/src/FocusableList.cc
@@ -169,7 +169,7 @@ bool FocusableList::insertFromParent(Focusable &win) {
     Focusables::iterator our_it = m_list.begin(), our_it_end = m_list.end();
     // walk through our list looking for corresponding entries in
     // parent's list, until we find the window that moved
-    for (; our_it != our_it_end && p_it != p_it_end; p_it++) {
+    for (; our_it != our_it_end && p_it != p_it_end; ++p_it) {
         if (*p_it == &win) {
             if (*our_it == &win) // win didn't move in our list
                 return false;
diff --git a/src/Keys.cc b/src/Keys.cc
index fc53353..f91c92e 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -146,7 +146,7 @@ public:
         // t_key ctor sets context_ of 0 to GLOBAL, so we must here too
         context_ = context_ ? context_ : GLOBAL;
         keylist_t::iterator it = keylist.begin(), it_end = keylist.end();
-        for (; it != it_end; it++) {
+        for (; it != it_end; ++it) {
             if (*it && (*it)->type == type_ && (*it)->key == key_ &&
                 ((*it)->context & context_) > 0 &&
                 isdouble_ == (*it)->isdouble && (*it)->mod ==
diff --git a/src/Remember.cc b/src/Remember.cc
index 10aa52c..c4eeb25 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -240,7 +240,7 @@ string escapeRememberChars(const string& str) {
     escaped_str.reserve(str.capacity());
 
     string::const_iterator i;
-    for (i = str.begin(); i != str.end(); i++) {
+    for (i = str.begin(); i != str.end(); ++i) {
         switch (*i) {
             case '(': case ')': case '[': case ']':
                 escaped_str += '\\';
@@ -671,7 +671,7 @@ Application* Remember::find(WinClient &winclient) {
         return wc_it->second;
     else {
         Patterns::iterator it = m_pats->begin();
-        for (; it != m_pats->end(); it++)
+        for (; it != m_pats->end(); ++it)
             if (it->first->match(winclient) &&
                 it->second->is_transient == winclient.isTransient()) {
                 it->first->addMatch();
@@ -893,7 +893,7 @@ void Remember::save() {
 
             Patterns::iterator git = m_pats->begin();
             Patterns::iterator git_end = m_pats->end();
-            for (; git != git_end; git++) {
+            for (; git != git_end; ++git) {
                 if (git->second == &a) {
                     apps_file << (a.is_transient ? " [transient]" : " [app]") <<
                                  git->first->toString()<<endl;
@@ -1389,7 +1389,7 @@ void Remember::updateClientClose(WinClient &winclient) {
 
     if (app) {
         Patterns::iterator it = m_pats->begin();
-        for (; it != m_pats->end(); it++) {
+        for (; it != m_pats->end(); ++it) {
             if (it->second == app) {
                 it->first->removeMatch();
                 break;
diff --git a/src/Screen.cc b/src/Screen.cc
index 309ee0d..4ea7afb 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -1981,9 +1981,9 @@ void BScreen::clearHeads() {
     if (!hasXinerama()) return;
 
     for (Workspaces::iterator i = m_workspaces_list.begin();
-            i != m_workspaces_list.end(); i++) {
+            i != m_workspaces_list.end(); ++i) {
         for (Workspace::Windows::iterator win = (*i)->windowList().begin();
-                win != (*i)->windowList().end(); win++) {
+                win != (*i)->windowList().end(); ++win) {
 
             FluxboxWindow& w = *(*win);
 
diff --git a/src/Slit.cc b/src/Slit.cc
index ccd60ab..02eb877 100644
--- a/src/Slit.cc
+++ b/src/Slit.cc
@@ -879,7 +879,7 @@ void Slit::clientUp(SlitClient* client) {
     }
 
     SlitClients::iterator it = m_client_list.begin();
-    for(it++; it != m_client_list.end(); it++) {
+    for(++it; it != m_client_list.end(); ++it) {
         if ((*it) == client) {
             SlitClients::iterator prev = it;
             prev--;
@@ -900,7 +900,7 @@ void Slit::clientDown(SlitClient* client) {
     }
 
     SlitClients::reverse_iterator it = m_client_list.rbegin();
-    for(it++; it != m_client_list.rend(); it++) {
+    for(++it; it != m_client_list.rend(); ++it) {
         if ((*it) == client) {
             SlitClients::reverse_iterator next = it;
             next--;
diff --git a/src/Window.cc b/src/Window.cc
index db5bacc..a4eef44 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -1345,7 +1345,7 @@ void FluxboxWindow::iconify() {
         WinClient &client = *(*client_it);
         WinClient::TransientList::iterator it = client.transientList().begin();
         WinClient::TransientList::iterator it_end = client.transientList().end();
-        for (; it != it_end; it++)
+        for (; it != it_end; ++it)
             if ((*it)->fbwindow())
                 (*it)->fbwindow()->iconify();
     }
@@ -2966,7 +2966,7 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) {
     Workspace::Windows::iterator it_end = wins.end();
 
     unsigned int bw;
-    for (; it != it_end; it++) {
+    for (; it != it_end; ++it) {
         if ((*it) == this)
             continue; // skip myself
 
diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.cc
index 34c8f9a..42cc05e 100644
--- a/src/WorkspaceCmd.cc
+++ b/src/WorkspaceCmd.cc
@@ -393,7 +393,7 @@ void ArrangeWindowsCmd::execute() {
 
     Workspace::Windows normal_windows;
     Workspace::Windows shaded_windows;
-    for(win = space->windowList().begin(); win != space->windowList().end(); win++) {
+    for(win = space->windowList().begin(); win != space->windowList().end(); ++win) {
         int winhead = screen->getHead((*win)->fbWindow());
         if ((winhead == head || winhead == 0) && m_pat.match(**win)) {
             if ((*win)->isShaded())
@@ -430,7 +430,7 @@ void ArrangeWindowsCmd::execute() {
     // TODO: until i resolve the shadedwindow->moveResize() issue to place
     // them in the same columns as the normal windows i just place the shaded
     // windows unchanged ontop of the current head
-    for (i = 0, win = shaded_windows.begin(); win != shaded_windows.end(); win++, i++) {
+    for (i = 0, win = shaded_windows.begin(); win != shaded_windows.end(); ++win, ++i) {
         if (i & 1)
             (*win)->move(x_offs, y_offs);
         else
@@ -449,7 +449,7 @@ void ArrangeWindowsCmd::execute() {
     // Resizes and sets windows positions in columns and rows.
     for (i = 0; i < rows; ++i) {
         x_offs = screen->maxLeft(head);
-        for (j = 0; j < cols && normal_windows.size() > 0; ++j) {
+        for (j = 0; j < cols && !normal_windows.empty(); ++j) {
 
 
             int cell_center_x = x_offs + (x_offs + cal_width) / 2;
@@ -457,7 +457,7 @@ void ArrangeWindowsCmd::execute() {
             unsigned int closest_dist = ~0;
 
             Workspace::Windows::iterator closest = normal_windows.end();
-            for (win = normal_windows.begin(); win != normal_windows.end(); win++) {
+            for (win = normal_windows.begin(); win != normal_windows.end(); ++win) {
 
                 int win_center_x = (*win)->frame().x() + ((*win)->frame().x() + (*win)->frame().width() / 2);
                 int win_center_y = (*win)->frame().y() + ((*win)->frame().y() + (*win)->frame().height() / 2);
@@ -519,7 +519,7 @@ void ShowDesktopCmd::execute() {
         BScreen::Icons icon_list = screen->iconList();
         BScreen::Icons::reverse_iterator iconit = icon_list.rbegin();
         BScreen::Icons::reverse_iterator itend= icon_list.rend();
-        for(; iconit != itend; iconit++) {
+        for(; iconit != itend; ++iconit) {
             if ((*iconit)->workspaceNumber() == space || (*iconit)->isStuck())
                 (*iconit)->deiconify(false);
         }
diff --git a/src/WorkspaceNameTool.cc b/src/WorkspaceNameTool.cc
index 84f62e5..5056a8f 100644
--- a/src/WorkspaceNameTool.cc
+++ b/src/WorkspaceNameTool.cc
@@ -88,7 +88,7 @@ unsigned int WorkspaceNameTool::width() const {
 
     const BScreen::Workspaces& workspaces = m_screen.getWorkspacesList();
     BScreen::Workspaces::const_iterator it;
-    for (it = workspaces.begin(); it != workspaces.end(); it++) {
+    for (it = workspaces.begin(); it != workspaces.end(); ++it) {
         max_size = std::max(m_theme->font().textWidth((*it)->name()), max_size);
     }
     // so align text dont cut the last character
@@ -104,7 +104,7 @@ unsigned int WorkspaceNameTool::height() const {
     unsigned int max_size = 0;
     const BScreen::Workspaces& workspaces = m_screen.getWorkspacesList();
     BScreen::Workspaces::const_iterator it;
-    for (it = workspaces.begin(); it != workspaces.end(); it++) {
+    for (it = workspaces.begin(); it != workspaces.end(); ++it) {
         max_size = std::max(m_theme->font().textWidth((*it)->name()), max_size);
     }
     // so align text dont cut the last character
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 8260897..77b9881 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -382,7 +382,7 @@ Fluxbox::Fluxbox(int argc, char **argv,
             int scrnr = 0;
             FbTk::StringUtil::stringtok(vals, m_argv[i], ",:");
             for (vector<string>::iterator scrit = vals.begin();
-                 scrit != vals.end(); scrit++) {
+                 scrit != vals.end(); ++scrit) {
                 scrnr = atoi(scrit->c_str());
                 if (scrnr >= 0 && scrnr < ScreenCount(disp))
                     scrtmp.push_back(scrnr);
@@ -711,7 +711,7 @@ void Fluxbox::handleEvent(XEvent * const e) {
         // most of them are handled in FluxboxWindow::handleEvent
         // but some special cases like ewmh propertys needs to be checked
         for (AtomHandlerContainerIt it= m_atomhandler.begin();
-             it != m_atomhandler.end(); it++) {
+             it != m_atomhandler.end(); ++it) {
             if ( (*it)->propertyNotify(*winclient, e->xproperty.atom))
                 break;
         }
@@ -880,7 +880,7 @@ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
         // note: we dont need screen nor winclient to be non-null,
         // it's up to the atomhandler to check that
         for (AtomHandlerContainerIt it= m_atomhandler.begin();
-             it != m_atomhandler.end(); it++) {
+             it != m_atomhandler.end(); ++it) {
             (*it)->checkClientMessage(ce, screen, winclient);
         }
 
@@ -1042,7 +1042,7 @@ AtomHandler* Fluxbox::getAtomHandler(const string &name) {
     if ( name != "" ) {
 
         AtomHandlerContainerIt it;
-        for (it = m_atomhandler.begin(); it != m_atomhandler.end(); it++) {
+        for (it = m_atomhandler.begin(); it != m_atomhandler.end(); ++it) {
             if (name == (*it)->getName())
                 return *it;
         }
@@ -1258,7 +1258,7 @@ void Fluxbox::load_rc(BScreen &screen) {
         StringUtil::removeFirstWhitespace(values);
         StringUtil::stringtok<BScreen::WorkspaceNames>(names, values, ",");
         BScreen::WorkspaceNames::iterator it;
-        for(it = names.begin(); it != names.end(); it++) {
+        for(it = names.begin(); it != names.end(); ++it) {
             if (!(*it).empty() && (*it) != "")
             screen.addWorkspaceName((*it).c_str());
         }
@@ -1385,7 +1385,7 @@ void Fluxbox::focusedWindowChanged(BScreen &screen,
                                    WinClient* client) {
 
     for (AtomHandlerContainerIt it= m_atomhandler.begin();
-         it != m_atomhandler.end(); it++) {
+         it != m_atomhandler.end(); ++it) {
         (*it)->updateFocusedWindow(screen, client ? client->window() : 0 );
     }
 }
-- 
cgit v0.11.2