From 876b88f106a20b3260cc511337c44d07234b360e Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 18 Dec 2023 16:41:01 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com> --- python/sdist/amici/cxxcodeprinter.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/python/sdist/amici/cxxcodeprinter.py b/python/sdist/amici/cxxcodeprinter.py index b57f03a2c1..76c7f67850 100644 --- a/python/sdist/amici/cxxcodeprinter.py +++ b/python/sdist/amici/cxxcodeprinter.py @@ -305,7 +305,7 @@ def get_switch_statement( """ Generate code for a C++ switch statement. - Generate code for a C++ switch statements with a ``break`` after each case. + Generate code for a C++ switch statement with a ``break`` after each case. :param condition: Condition for switch @@ -343,12 +343,7 @@ def get_switch_statement( ) case_code = f"{indent1}case {expression}:" - try: - # there is already a case with the same statement, append - cases_map[statement_code].append(case_code) - except KeyError: - # add new case + statement - cases_map[statement_code] = [case_code] + cases_map[statement_code] = cases_map.get(statement_code, []) + [case_code] if not cases_map: return []