Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc6f2ef

Browse files
committed
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
1 parent 3902d62 commit fc6f2ef

1 file changed

Lines changed: 9 additions & 26 deletions

File tree

Python/compile.c

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ static int compiler_addop(struct compiler *, int);
171171
static int compiler_addop_o(struct compiler *, int, PyObject *, PyObject *);
172172
static int compiler_addop_i(struct compiler *, int, Py_ssize_t);
173173
static int compiler_addop_j(struct compiler *, int, basicblock *, int);
174-
static basicblock *compiler_use_new_block(struct compiler *);
175174
static int compiler_error(struct compiler *, const char *);
176175
static int compiler_nameop(struct compiler *, identifier, expr_context_ty);
177176

@@ -523,6 +522,7 @@ compiler_enter_scope(struct compiler *c, identifier name,
523522
int scope_type, void *key, int lineno)
524523
{
525524
struct compiler_unit *u;
525+
basicblock *block;
526526

527527
u = (struct compiler_unit *)PyObject_Malloc(sizeof(
528528
struct compiler_unit));
@@ -620,8 +620,11 @@ compiler_enter_scope(struct compiler *c, identifier name,
620620
c->u = u;
621621

622622
c->c_nestlevel++;
623-
if (compiler_use_new_block(c) == NULL)
623+
624+
block = compiler_new_block(c);
625+
if (block == NULL)
624626
return 0;
627+
c->u->u_curblock = block;
625628

626629
if (u->u_scope_type != COMPILER_SCOPE_MODULE) {
627630
if (!compiler_set_qualname(c))
@@ -755,16 +758,6 @@ compiler_new_block(struct compiler *c)
755758
return b;
756759
}
757760

758-
static basicblock *
759-
compiler_use_new_block(struct compiler *c)
760-
{
761-
basicblock *block = compiler_new_block(c);
762-
if (block == NULL)
763-
return NULL;
764-
c->u->u_curblock = block;
765-
return block;
766-
}
767-
768761
static basicblock *
769762
compiler_next_block(struct compiler *c)
770763
{
@@ -1208,22 +1201,12 @@ compiler_addop_j(struct compiler *c, int opcode, basicblock *b, int absolute)
12081201
return 1;
12091202
}
12101203

1211-
/* The distinction between NEW_BLOCK and NEXT_BLOCK is subtle. (I'd
1212-
like to find better names.) NEW_BLOCK() creates a new block and sets
1213-
it as the current block. NEXT_BLOCK() also creates an implicit jump
1214-
from the current block to the new block.
1215-
*/
1204+
/* NEXT_BLOCK() creates an implicit jump from the current block
1205+
to the new block.
12161206
1217-
/* The returns inside these macros make it impossible to decref objects
1218-
created in the local function. Local objects should use the arena.
1207+
The returns inside this macro make it impossible to decref objects
1208+
created in the local function. Local objects should use the arena.
12191209
*/
1220-
1221-
1222-
#define NEW_BLOCK(C) { \
1223-
if (compiler_use_new_block((C)) == NULL) \
1224-
return 0; \
1225-
}
1226-
12271210
#define NEXT_BLOCK(C) { \
12281211
if (compiler_next_block((C)) == NULL) \
12291212
return 0; \

0 commit comments

Comments
 (0)