Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
7711afbb
Commit
7711afbb
authored
10 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Combine complie functions for or_test/and_test to reduce code size.
Saves around 60 bytes code on Thumb2 archs.
parent
63f3832e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/compile.c
+7
-11
7 additions, 11 deletions
py/compile.c
with
7 additions
and
11 deletions
py/compile.c
+
7
−
11
View file @
7711afbb
...
...
@@ -2253,28 +2253,24 @@ STATIC void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
close_over_variables_etc
(
comp
,
this_scope
,
0
,
0
);
}
STATIC
void
compile_or_test
(
compiler_t
*
comp
,
mp_parse_node_struct_t
*
pns
)
{
STATIC
void
compile_or_
and_
test
(
compiler_t
*
comp
,
mp_parse_node_struct_t
*
pns
,
bool
cond
)
{
uint
l_end
=
comp_next_label
(
comp
);
int
n
=
MP_PARSE_NODE_STRUCT_NUM_NODES
(
pns
);
for
(
int
i
=
0
;
i
<
n
;
i
+=
1
)
{
compile_node
(
comp
,
pns
->
nodes
[
i
]);
if
(
i
+
1
<
n
)
{
EMIT_ARG
(
jump_if_or_pop
,
true
,
l_end
);
EMIT_ARG
(
jump_if_or_pop
,
cond
,
l_end
);
}
}
EMIT_ARG
(
label_assign
,
l_end
);
}
STATIC
void
compile_or_test
(
compiler_t
*
comp
,
mp_parse_node_struct_t
*
pns
)
{
compile_or_and_test
(
comp
,
pns
,
true
);
}
STATIC
void
compile_and_test
(
compiler_t
*
comp
,
mp_parse_node_struct_t
*
pns
)
{
uint
l_end
=
comp_next_label
(
comp
);
int
n
=
MP_PARSE_NODE_STRUCT_NUM_NODES
(
pns
);
for
(
int
i
=
0
;
i
<
n
;
i
+=
1
)
{
compile_node
(
comp
,
pns
->
nodes
[
i
]);
if
(
i
+
1
<
n
)
{
EMIT_ARG
(
jump_if_or_pop
,
false
,
l_end
);
}
}
EMIT_ARG
(
label_assign
,
l_end
);
compile_or_and_test
(
comp
,
pns
,
false
);
}
STATIC
void
compile_not_test_2
(
compiler_t
*
comp
,
mp_parse_node_struct_t
*
pns
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment