From: Michal Jarzabek Date: Sat, 6 Aug 2016 07:26:14 +0000 (+0100) Subject: mon/MonClient.h: remove repeated searching of map X-Git-Tag: v11.1.0~695^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=22328b82b260af9d28ae25b5ebd69e7c46d25c5e;p=ceph.git mon/MonClient.h: remove repeated searching of map Signed-off-by: Michal Jarzabek --- diff --git a/src/mon/MonClient.h b/src/mon/MonClient.h index f0383880ec9..2966310c18d 100644 --- a/src/mon/MonClient.h +++ b/src/mon/MonClient.h @@ -210,14 +210,19 @@ private: void handle_subscribe_ack(MMonSubscribeAck* m); bool _sub_want(const string &what, version_t start, unsigned flags) { - if ((sub_new.count(what) == 0 && - sub_sent.count(what) && - sub_sent[what].start == start && - sub_sent[what].flags == flags) || - (sub_new.count(what) && - sub_new[what].start == start && - sub_new[what].flags == flags)) + auto sub = sub_new.find(what); + if (sub != sub_new.end() && + sub->second.start == start && + sub->second.flags == flags) { return false; + } else { + sub = sub_sent.find(what); + if (sub != sub_sent.end() && + sub->second.start == start && + sub->second.flags == flags) + return false; + } + sub_new[what].start = start; sub_new[what].flags = flags; return true;