summaryrefslogtreecommitdiff
path: root/py/compile.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-09-23 11:47:01 +0100
committerDamien George <damien.p.george@gmail.com>2015-09-23 11:47:01 +0100
commitfbcaf0ea18d647adc445dc1029392c2a908cf540 (patch)
treea58fc009888d9cfdcb2dd5c07499e848228329fb /py/compile.c
parente6978a4e26a17ef473e2aad78662d3bf29638578 (diff)
py: Slightly simplify compile and emit of star/double-star arguments.
Saves a few bytes of code space and eliminates need for rot_two bytecode (hence saving RAM and execution time, by a tiny bit).
Diffstat (limited to 'py/compile.c')
-rw-r--r--py/compile.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/py/compile.c b/py/compile.c
index 9ac37c6d9..82a27bb0b 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -2252,11 +2252,18 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar
}
// compile the star/double-star arguments if we had them
- if (star_args_node != NULL) {
- compile_node(comp, star_args_node->nodes[0]);
- }
- if (dblstar_args_node != NULL) {
- compile_node(comp, dblstar_args_node->nodes[0]);
+ // if we had one but not the other then we load "null" as a place holder
+ if (star_flags != 0) {
+ if (star_args_node == NULL) {
+ EMIT(load_null);
+ } else {
+ compile_node(comp, star_args_node->nodes[0]);
+ }
+ if (dblstar_args_node == NULL) {
+ EMIT(load_null);
+ } else {
+ compile_node(comp, dblstar_args_node->nodes[0]);
+ }
}
// emit the function/method call