Commit eef325b1 by Evan Brown Committed by Copybara-Service

Add braces for conditional statements in raw_hash_map functions.

The current version violates the Google C++ style guide - see https://google.github.io/styleguide/cppguide.html#Formatting_Looping_Branching. This code does not fit into the historical exception that "the curly braces for the controlled statement or the line breaks inside the curly braces may be omitted if as a result the entire statement appears on either a single line (in which case there is a space between the closing parenthesis and the controlled statement) or on two lines (in which case there is a line break after the closing parenthesis and there are no braces)."

PiperOrigin-RevId: 609789188
Change-Id: Id7ae9596e454dac5581d19939564c07670077f92
parent d87dc03c
...@@ -198,10 +198,11 @@ class raw_hash_map : public raw_hash_set<Policy, Hash, Eq, Alloc> { ...@@ -198,10 +198,11 @@ class raw_hash_map : public raw_hash_set<Policy, Hash, Eq, Alloc> {
std::pair<iterator, bool> insert_or_assign_impl(K&& k, V&& v) std::pair<iterator, bool> insert_or_assign_impl(K&& k, V&& v)
ABSL_ATTRIBUTE_LIFETIME_BOUND { ABSL_ATTRIBUTE_LIFETIME_BOUND {
auto res = this->find_or_prepare_insert(k); auto res = this->find_or_prepare_insert(k);
if (res.second) if (res.second) {
this->emplace_at(res.first, std::forward<K>(k), std::forward<V>(v)); this->emplace_at(res.first, std::forward<K>(k), std::forward<V>(v));
else } else {
Policy::value(&*res.first) = std::forward<V>(v); Policy::value(&*res.first) = std::forward<V>(v);
}
return res; return res;
} }
...@@ -209,10 +210,11 @@ class raw_hash_map : public raw_hash_set<Policy, Hash, Eq, Alloc> { ...@@ -209,10 +210,11 @@ class raw_hash_map : public raw_hash_set<Policy, Hash, Eq, Alloc> {
std::pair<iterator, bool> try_emplace_impl(K&& k, Args&&... args) std::pair<iterator, bool> try_emplace_impl(K&& k, Args&&... args)
ABSL_ATTRIBUTE_LIFETIME_BOUND { ABSL_ATTRIBUTE_LIFETIME_BOUND {
auto res = this->find_or_prepare_insert(k); auto res = this->find_or_prepare_insert(k);
if (res.second) if (res.second) {
this->emplace_at(res.first, std::piecewise_construct, this->emplace_at(res.first, std::piecewise_construct,
std::forward_as_tuple(std::forward<K>(k)), std::forward_as_tuple(std::forward<K>(k)),
std::forward_as_tuple(std::forward<Args>(args)...)); std::forward_as_tuple(std::forward<Args>(args)...));
}
return res; return res;
} }
}; };
......
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