Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ef0a82b6
Commit
ef0a82b6
authored
Aug 25, 2004
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify chains of conditional jumps.
(Suggested by Neal Norwitz.)
parent
08b07def
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
2 deletions
+25
-2
Python/compile.c
Python/compile.c
+25
-2
No files found.
Python/compile.c
View file @
ef0a82b6
...
...
@@ -550,11 +550,34 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
}
break
;
/* Simplify conditional jump to conditional jump where the
result of the first test implies the success of a similar
test or the failure of the opposite test.
Arises in code like:
"a and b or c"
"a and b and c"
x:JUMP_IF_FALSE y y:JUMP_IF_FALSE z --> x:JUMP_IF_FALSE z
x:JUMP_IF_FALSE y y:JUMP_IF_FALSE z --> x:JUMP_IF_FALSE y+3
*/
case
JUMP_IF_FALSE
:
case
JUMP_IF_TRUE
:
tgt
=
GETJUMPTGT
(
codestr
,
i
);
j
=
codestr
[
tgt
];
if
(
j
==
JUMP_IF_FALSE
||
j
==
JUMP_IF_TRUE
)
{
if
(
j
==
opcode
)
{
tgttgt
=
GETJUMPTGT
(
codestr
,
tgt
)
-
i
-
3
;
SETARG
(
codestr
,
i
,
tgttgt
);
}
else
{
tgt
-=
i
;
SETARG
(
codestr
,
i
,
tgt
);
}
break
;
}
/* Intentional fallthrough */
/* Replace jumps to unconditional jumps */
case
FOR_ITER
:
case
JUMP_FORWARD
:
case
JUMP_IF_FALSE
:
case
JUMP_IF_TRUE
:
case
JUMP_ABSOLUTE
:
case
CONTINUE_LOOP
:
case
SETUP_LOOP
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment