]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106360: remove redundant #ifdef (#106622)
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Tue, 11 Jul 2023 12:41:50 +0000 (15:41 +0300)
committerGitHub <noreply@github.com>
Tue, 11 Jul 2023 12:41:50 +0000 (13:41 +0100)
Python/opcode_metadata.h
Tools/cases_generator/generate_cases.py

index ce2384ee2e4833bd67f561c3a90b8848bece4ff0..34ac85d6517a88bebc32f4b42f2c09feac545baa 100644 (file)
@@ -960,7 +960,7 @@ struct opcode_macro_expansion {
 extern const struct opcode_metadata _PyOpcode_opcode_metadata[512];
 extern const struct opcode_macro_expansion _PyOpcode_macro_expansion[256];
 extern const char * const _PyOpcode_uop_name[512];
-#else
+#else // if NEED_OPCODE_METADATA
 const struct opcode_metadata _PyOpcode_opcode_metadata[512] = {
     [NOP] = { true, INSTR_FMT_IX, 0 },
     [RESUME] = { true, INSTR_FMT_IB, HAS_ARG_FLAG },
@@ -1293,7 +1293,6 @@ const struct opcode_macro_expansion _PyOpcode_macro_expansion[256] = {
     [BINARY_OP] = { .nuops = 1, .uops = { { BINARY_OP, 0, 0 } } },
     [SWAP] = { .nuops = 1, .uops = { { SWAP, 0, 0 } } },
 };
-#ifdef NEED_OPCODE_METADATA
 const char * const _PyOpcode_uop_name[512] = {
     [300] = "EXIT_TRACE",
     [301] = "SAVE_IP",
@@ -1314,4 +1313,3 @@ const char * const _PyOpcode_uop_name[512] = {
     [316] = "IS_NONE",
 };
 #endif // NEED_OPCODE_METADATA
-#endif
index 932d0c14d398abc610e0854684077952ee494e98..641a327b06aa22bc3cdf98c61ce7ef6080ea9eb3 100644 (file)
@@ -1240,7 +1240,7 @@ class Analyzer:
             self.out.emit("extern const struct opcode_metadata _PyOpcode_opcode_metadata[512];")
             self.out.emit("extern const struct opcode_macro_expansion _PyOpcode_macro_expansion[256];")
             self.out.emit("extern const char * const _PyOpcode_uop_name[512];")
-            self.out.emit("#else")
+            self.out.emit("#else // if NEED_OPCODE_METADATA")
 
             self.out.emit("const struct opcode_metadata _PyOpcode_opcode_metadata[512] = {")
 
@@ -1289,12 +1289,10 @@ class Analyzer:
                         case _:
                             typing.assert_never(thing)
 
-            self.out.emit("#ifdef NEED_OPCODE_METADATA")
             with self.out.block("const char * const _PyOpcode_uop_name[512] =", ";"):
                 self.write_uop_items(lambda name, counter: f"[{counter}] = \"{name}\",")
-            self.out.emit("#endif // NEED_OPCODE_METADATA")
 
-            self.out.emit("#endif")
+            self.out.emit("#endif // NEED_OPCODE_METADATA")
 
         with open(self.pymetadata_filename, "w") as f:
             # Create formatter