From 5b8a5059068b8b783769d1306f529921b4c29956 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Fri, 15 Mar 2013 12:33:12 +0100 Subject: [PATCH] rados.cc: prefer prefix ++operator for iterators Prefer prefix ++operator for iterators, move some iterator declaration into the for-loop header, since the iterator is only used within the loop. Signed-off-by: Danny Al-Gaaf --- src/rados.cc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/rados.cc b/src/rados.cc index 51f998c1894c5..6856491014b4a 100644 --- a/src/rados.cc +++ b/src/rados.cc @@ -742,8 +742,7 @@ int LoadGen::run() cout << "waiting for all operations to complete" << std::endl; // now wait on all the pending requests - vector::iterator citer; - for (citer = completions.begin(); citer != completions.end(); citer++) { + for (vector::iterator citer = completions.begin(); citer != completions.end(); ++citer) { librados::AioCompletion *c = *citer; c->wait_for_complete(); c->release(); @@ -1733,7 +1732,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, header.hexdump(cout); cout << "\n"; cout << kv.size() << " keys\n"; - for (map::iterator q = kv.begin(); q != kv.end(); q++) { + for (map::iterator q = kv.begin(); q != kv.end(); ++q) { cout << "key '" << q->first << "' (" << q->second.length() << " bytes):\n"; q->second.hexdump(cout); cout << "\n"; @@ -1823,7 +1822,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, io_ctx.snap_list(&snaps); for (vector::iterator i = snaps.begin(); i != snaps.end(); - i++) { + ++i) { string s; time_t t; if (io_ctx.snap_get_name(*i, &s) < 0) @@ -2018,8 +2017,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, else ret = 0; - std::list::iterator i; - for (i = lw.begin(); i != lw.end(); i++) { + for (std::list::iterator i = lw.begin(); i != lw.end(); ++i) { cout << "watcher=client." << i->watcher_id << " cookie=" << i->cookie << std::endl; } } else if (strcmp(nargs[0], "listsnaps") == 0) { @@ -2042,7 +2040,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, vector snaps; io_ctx.snap_list(&snaps); for (vector::iterator i = snaps.begin(); - i != snaps.end(); i++) { + i != snaps.end(); ++i) { string s; if (io_ctx.snap_get_name(*i, &s) < 0) continue; @@ -2060,7 +2058,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } for (std::vector::iterator ci = ls.clones.begin(); - ci != ls.clones.end(); ci++) { + ci != ls.clones.end(); ++ci) { if (formatter) formatter->open_object_section("clone"); @@ -2120,7 +2118,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, cout << "\t["; for (std::vector< std::pair >::iterator ovi = ci->overlap.begin(); - ovi != ci->overlap.end(); ovi++) { + ovi != ci->overlap.end(); ++ovi) { if (formatter) { formatter->open_object_section("section"); formatter->dump_unsigned("start", ovi->first); @@ -2244,7 +2242,7 @@ int main(int argc, const char **argv) } else { if (val[0] == '-') usage_exit(); - i++; + ++i; } } -- 2.39.5