adjust code

This commit is contained in:
mutouyun 2019-01-02 12:37:18 +08:00
parent 2e26176234
commit eae565dfc8
2 changed files with 6 additions and 4 deletions

View File

@ -41,6 +41,11 @@ enum : std::size_t {
base_size = sizeof(void*)
};
template <std::size_t Radix>
constexpr std::size_t roundup(std::size_t n) {
return ((n - 1) & (~(Radix - 1))) + Radix;
}
using fixed_sequence_t = std::index_sequence<
base_size , base_size * 2 ,
base_size * 3 , base_size * 4 ,
@ -54,8 +59,7 @@ using fixed_sequence_t = std::index_sequence<
template <typename F>
decltype(auto) choose(std::size_t size, F&& f) {
size = ((size - 1) & (~(base_size - 1))) + base_size;
return detail::static_switch(size, fixed_sequence_t {
return detail::static_switch(roundup<base_size>(size), fixed_sequence_t {
}, [&f](auto index) {
return f(fixed<decltype(index)::value>());
}, [&f] {

View File

@ -87,8 +87,6 @@ void Unit::initTestCase() {
for (int i = 0; i < LoopCount; ++i) {
sizes__.emplace_back(static_cast<std::size_t>(rdm()));
}
ipc::mem::pool_alloc::clear();
}
void Unit::cleanupTestCase() {