[Python-checkins] cpython: compile.c: inline compiler_use_new_block()
victor.stinner
python-checkins at python.org
Fri Feb 26 20:26:23 EST 2016
https://hg.python.org/cpython/rev/b9e5be743d15
changeset: 100354:b9e5be743d15
user: Victor Stinner <victor.stinner at gmail.com>
date: Sat Feb 27 02:19:22 2016 +0100
summary:
compile.c: inline compiler_use_new_block()
* Inline compiler_use_new_block() function into its only callee,
compiler_enter_scope()
* Remove unused NEW_BLOCK() macro
files:
Python/compile.c | 37 +++++++++--------------------------
1 files changed, 10 insertions(+), 27 deletions(-)
diff --git a/Python/compile.c b/Python/compile.c
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -171,7 +171,6 @@
static int compiler_addop_o(struct compiler *, int, PyObject *, PyObject *);
static int compiler_addop_i(struct compiler *, int, Py_ssize_t);
static int compiler_addop_j(struct compiler *, int, basicblock *, int);
-static basicblock *compiler_use_new_block(struct compiler *);
static int compiler_error(struct compiler *, const char *);
static int compiler_nameop(struct compiler *, identifier, expr_context_ty);
@@ -523,6 +522,7 @@
int scope_type, void *key, int lineno)
{
struct compiler_unit *u;
+ basicblock *block;
u = (struct compiler_unit *)PyObject_Malloc(sizeof(
struct compiler_unit));
@@ -620,8 +620,11 @@
c->u = u;
c->c_nestlevel++;
- if (compiler_use_new_block(c) == NULL)
+
+ block = compiler_new_block(c);
+ if (block == NULL)
return 0;
+ c->u->u_curblock = block;
if (u->u_scope_type != COMPILER_SCOPE_MODULE) {
if (!compiler_set_qualname(c))
@@ -756,16 +759,6 @@
}
static basicblock *
-compiler_use_new_block(struct compiler *c)
-{
- basicblock *block = compiler_new_block(c);
- if (block == NULL)
- return NULL;
- c->u->u_curblock = block;
- return block;
-}
-
-static basicblock *
compiler_next_block(struct compiler *c)
{
basicblock *block = compiler_new_block(c);
@@ -1208,22 +1201,12 @@
return 1;
}
-/* The distinction between NEW_BLOCK and NEXT_BLOCK is subtle. (I'd
- like to find better names.) NEW_BLOCK() creates a new block and sets
- it as the current block. NEXT_BLOCK() also creates an implicit jump
- from the current block to the new block.
+/* NEXT_BLOCK() creates an implicit jump from the current block
+ to the new block.
+
+ The returns inside this macro make it impossible to decref objects
+ created in the local function. Local objects should use the arena.
*/
-
-/* The returns inside these macros make it impossible to decref objects
- created in the local function. Local objects should use the arena.
-*/
-
-
-#define NEW_BLOCK(C) { \
- if (compiler_use_new_block((C)) == NULL) \
- return 0; \
-}
-
#define NEXT_BLOCK(C) { \
if (compiler_next_block((C)) == NULL) \
return 0; \
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list