From bd850fdbde7ae403a501eec4fd551cfe0aae3909 Mon Sep 17 00:00:00 2001 From: Alper Yoney Date: Mon, 23 Dec 2024 13:27:17 -0800 Subject: [PATCH] Simplify boolean expresions Summary: Simplify few boolean expressions Reviewed By: Filip-F Differential Revision: D67604520 fbshipit-source-id: c174d47e7497cc4039e20ae0eee483a306907294 --- thrift/compiler/generate/json.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/thrift/compiler/generate/json.cc b/thrift/compiler/generate/json.cc index 9fb6c27ce19..7973328282d 100644 --- a/thrift/compiler/generate/json.cc +++ b/thrift/compiler/generate/json.cc @@ -31,9 +31,7 @@ namespace { void rtrim(std::string& s) { s.erase( std::find_if( - s.rbegin(), - s.rend(), - [](int ch) { return !(ch == ' ' || ch == ','); }) + s.rbegin(), s.rend(), [](int ch) { return ch != ' ' && ch != ','; }) .base(), s.end()); } @@ -102,7 +100,7 @@ std::ostream& json_quote_ascii(std::ostream& o, const std::string& s) { // clang-format on default: { uint8_t b = static_cast(c); - if (!(b >= 0x20 && b < 0x80)) { + if (b < 0x20 || b >= 0x80) { constexpr auto hex = "0123456789abcdef"; auto c1 = static_cast(hex[(b >> 4) & 0x0f]); auto c0 = static_cast(hex[(b >> 0) & 0x0f]);