Commit 0f1c675a authored by Stepan Palamarchuk's avatar Stepan Palamarchuk Committed by Facebook Github Bot

Use std::array instead of std::vector for bitmap

Summary: The size of the vector is essentially 4, there's no point of allocating it on heap. This improves locality and avoids unnecessary indirection.

Reviewed By: jmswen

Differential Revision: D13709524

fbshipit-source-id: 76c80b835a73ec8f7f5096ae927292571d137596
parent f08d42c0
...@@ -86,7 +86,7 @@ HHWheelTimer::HHWheelTimer( ...@@ -86,7 +86,7 @@ HHWheelTimer::HHWheelTimer(
count_(0), count_(0),
startTime_(getCurTime()), startTime_(getCurTime()),
processingCallbacksGuard_(nullptr) { processingCallbacksGuard_(nullptr) {
bitmap_.resize((WHEEL_SIZE / sizeof(std::size_t)) / 8, 0); bitmap_.fill(0);
} }
HHWheelTimer::~HHWheelTimer() { HHWheelTimer::~HHWheelTimer() {
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <boost/intrusive/list.hpp> #include <boost/intrusive/list.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <array>
#include <chrono> #include <chrono>
#include <cstddef> #include <cstddef>
#include <memory> #include <memory>
...@@ -278,7 +279,7 @@ class HHWheelTimer : private folly::AsyncTimeout, ...@@ -278,7 +279,7 @@ class HHWheelTimer : private folly::AsyncTimeout,
typedef Callback::List CallbackList; typedef Callback::List CallbackList;
CallbackList buckets_[WHEEL_BUCKETS][WHEEL_SIZE]; CallbackList buckets_[WHEEL_BUCKETS][WHEEL_SIZE];
std::vector<std::size_t> bitmap_; std::array<std::size_t, (WHEEL_SIZE / sizeof(std::size_t)) / 8> bitmap_;
int64_t timeToWheelTicks(std::chrono::milliseconds t) { int64_t timeToWheelTicks(std::chrono::milliseconds t) {
return t.count() / interval_.count(); return t.count() / interval_.count();
......
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