This is an automated email from the ASF dual-hosted git repository.
wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 89fa47b6 + Swap allocator in FlatMap::resize (#2160)
89fa47b6 is described below
commit 89fa47b607c2b64eca12366a0211bffa01cda583
Author: old-bear <[email protected]>
AuthorDate: Mon Mar 13 09:52:01 2023 +0800
+ Swap allocator in FlatMap::resize (#2160)
---
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]