Commit 38bbc80e authored by Dan Melnic's avatar Dan Melnic Committed by Facebook GitHub Bot

Avoid traversing the callbacks map twice when inserting a non-existing entry

Summary: Avoid traversing the callbacks map twice when inserting a non-existing entry

Reviewed By: kevin-vigor

Differential Revision: D23030404

fbshipit-source-id: afbf7564f4039ffbd942f407429874fde795025d
parent 23b4e99c
...@@ -50,14 +50,7 @@ void TimerFDTimeoutManager::scheduleTimeout( ...@@ -50,14 +50,7 @@ void TimerFDTimeoutManager::scheduleTimeout(
// now add the callback // now add the callback
// handle entries that expire at the same time // handle entries that expire at the same time
auto iter = callbacks_.find(expirationTimeUsec); callbacks_[expirationTimeUsec].push_back(*callback);
if (iter != callbacks_.end()) {
iter->second.push_back(*callback);
} else {
CallbackList list;
list.push_back(*callback);
callbacks_.emplace(expirationTimeUsec, std::move(list));
}
callback->setExpirationTime(this, expirationTimeUsec); callback->setExpirationTime(this, expirationTimeUsec);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment