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 64bc8d9c refactor: reduce code for operator[] of FlatMap (#2202)
64bc8d9c is described below
commit 64bc8d9c329d853bd184efe9ac85ae34cc1dc4f5
Author: 王勇 <[email protected]>
AuthorDate: Wed Apr 26 11:32:10 2023 +0800
refactor: reduce code for operator[] of FlatMap (#2202)
---
src/butil/containers/flat_map_inl.h | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/src/butil/containers/flat_map_inl.h
b/src/butil/containers/flat_map_inl.h
index f79fcb86..264d28c7 100644
--- a/src/butil/containers/flat_map_inl.h
+++ b/src/butil/containers/flat_map_inl.h
@@ -522,22 +522,7 @@ _T& FlatMap<_K, _T, _H, _E, _S, _A>::operator[](const
key_type& key) {
new (&first_node) Bucket(key);
return first_node.element().second_ref();
}
- if (_eql(first_node.element().first_ref(), key)) {
- return first_node.element().second_ref();
- }
- Bucket *p = first_node.next;
- if (NULL == p) {
- if (is_too_crowded(_size)) {
- if (resize(_nbucket + 1)) {
- return operator[](key);
- }
- // fail to resize is OK
- }
- ++_size;
- Bucket* newp = new (_pool.get()) Bucket(key);
- first_node.next = newp;
- return newp->element().second_ref();
- }
+ Bucket *p = &first_node;
while (1) {
if (_eql(p->element().first_ref(), key)) {
return p->element().second_ref();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]