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."
This commit is contained in:
Ryan Pavlik 2011-11-02 13:33:38 -04:00 committed by Mathias Gumz
parent f859e78cb2
commit 5ae8bdf49d
16 changed files with 36 additions and 36 deletions

View file

@ -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()) {

View file

@ -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);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;
}
}

View file

@ -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);
}

View file

@ -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;

View file

@ -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 ==

View file

@ -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;

View file

@ -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);

View file

@ -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--;

View file

@ -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

View file

@ -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);
}

View file

@ -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

View file

@ -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 );
}
}