This is an automated email from the ASF dual-hosted git repository. jrjbear pushed a commit to branch fix-flat-map-allocator in repository https://gitbox.apache.org/repos/asf/brpc.git
commit 9e627588fe3b2a75a6cf67de617d5ae3acc6d3f7 Author: oldbear <[email protected]> AuthorDate: Sat Mar 11 11:42:00 2023 +0800 + Swap allocator in FlatMap::resize --- src/butil/containers/flat_map_inl.h | 4 +--- src/butil/single_threaded_pool.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/butil/containers/flat_map_inl.h b/src/butil/containers/flat_map_inl.h index 8c87bb17..3bd64e64 100644 --- a/src/butil/containers/flat_map_inl.h +++ b/src/butil/containers/flat_map_inl.h @@ -607,11 +607,9 @@ bool FlatMap<_K, _T, _H, _E, _S, _A>::resize(size_t nbucket2) { return false; } - FlatMap new_map; // NOTE: following functors must be kept after resizing otherwise the // internal state is lost. - new_map._hashfn = _hashfn; - new_map._eql = _eql; + FlatMap new_map(_hashfn, _eql, get_allocator()); if (new_map.init(nbucket2, _load_factor) != 0) { LOG(ERROR) << "Fail to init new_map, nbucket=" << nbucket2; return false; diff --git a/src/butil/single_threaded_pool.h b/src/butil/single_threaded_pool.h index f1b28e03..591e423f 100644 --- a/src/butil/single_threaded_pool.h +++ b/src/butil/single_threaded_pool.h @@ -68,6 +68,7 @@ public: void swap(SingleThreadedPool & other) { std::swap(_free_nodes, other._free_nodes); std::swap(_blocks, other._blocks); + std::swap(_allocator, other._allocator); } // Get space of an item. The space is as long as ITEM_SIZE. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
