From 562bb76b5c3c97dc77aa733cdeb89c53c407ad1b Mon Sep 17 00:00:00 2001 From: Plotnus Date: Mon, 25 Apr 2022 15:05:11 -0600 Subject: [PATCH] Simplified if statement I believe this change simplifies things as they are logical equivalents. Classic example of the following which happens a lot. ``` bool b = false; if (expr) { b = true; } // same as bool b = expr; ``` --- epi_judge_cpp_solutions/string_integer_interconversion.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/epi_judge_cpp_solutions/string_integer_interconversion.cc b/epi_judge_cpp_solutions/string_integer_interconversion.cc index 3295fe5b7..777ee8e59 100644 --- a/epi_judge_cpp_solutions/string_integer_interconversion.cc +++ b/epi_judge_cpp_solutions/string_integer_interconversion.cc @@ -8,10 +8,7 @@ using std::accumulate; using std::string; string IntToString(int x) { - bool is_negative = false; - if (x < 0) { - is_negative = true; - } + bool is_negative = x < 0; string s; do {