Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osd/ReplicatedPG: remove unneeded use of count #11251

Merged
merged 1 commit into from
Nov 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/osd/ReplicatedPG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,9 @@ bool ReplicatedPG::is_degraded_or_backfilling_object(const hobject_t& soid)
++i) {
if (*i == get_primary()) continue;
pg_shard_t peer = *i;
if (peer_missing.count(peer) &&
peer_missing[peer].get_items().count(soid))
auto peer_missing_entry = peer_missing.find(peer);
if (peer_missing_entry != peer_missing.end() &&
peer_missing_entry->second.get_items().count(soid))
return true;

// Object is degraded if after last_backfill AND
Expand Down Expand Up @@ -5936,8 +5937,9 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
for (map<string, pair<bufferlist, int> >::iterator i = assertions.begin();
i != assertions.end();
++i) {
bufferlist &bl = out.count(i->first) ?
out[i->first] : empty;
auto out_entry = out.find(i->first);
bufferlist &bl = (out_entry != out.end()) ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we don't reuse out_entry, i think the use of count() here is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liewegas
I forgotten to use it in the next line, I have pushed the corrected commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. Thanks!

out_entry->second : empty;
switch (i->second.second) {
case CEPH_OSD_CMPXATTR_OP_EQ:
if (!(bl == i->second.first)) {
Expand Down Expand Up @@ -6665,8 +6667,9 @@ void ReplicatedPG::complete_disconnect_watches(
i != to_disconnect.end();
++i) {
pair<uint64_t, entity_name_t> watcher(i->cookie, i->name);
if (obc->watchers.count(watcher)) {
WatchRef watch = obc->watchers[watcher];
auto watchers_entry = obc->watchers.find(watcher);
if (watchers_entry != obc->watchers.end()) {
WatchRef watch = watchers_entry->second;
dout(10) << "do_osd_op_effects disconnect watcher " << watcher << dendl;
obc->watchers.erase(watcher);
watch->remove(i->send_disconnect);
Expand Down