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
3267f872
Commit
3267f872
authored
Dec 04, 2007
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove special-casing of integer operations, to stop
using PyInt_CheckExact.
parent
8b0facf8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
91 deletions
+6
-91
Python/ceval.c
Python/ceval.c
+6
-91
No files found.
Python/ceval.c
View file @
3267f872
...
...
@@ -1118,24 +1118,13 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
case
BINARY_ADD
:
w
=
POP
();
v
=
TOP
();
if
(
PyInt_CheckExact
(
v
)
&&
PyInt_CheckExact
(
w
))
{
/* INLINE: int + int */
register
long
a
,
b
,
i
;
a
=
PyLong_AS_LONG
(
v
);
b
=
PyLong_AS_LONG
(
w
);
i
=
a
+
b
;
if
((
i
^
a
)
<
0
&&
(
i
^
b
)
<
0
)
goto
slow_add
;
x
=
PyLong_FromLong
(
i
);
}
else
if
(
PyUnicode_CheckExact
(
v
)
&&
if
(
PyUnicode_CheckExact
(
v
)
&&
PyUnicode_CheckExact
(
w
))
{
x
=
unicode_concatenate
(
v
,
w
,
f
,
next_instr
);
/* unicode_concatenate consumed the ref to v */
goto
skip_decref_vx
;
}
else
{
slow_add:
x
=
PyNumber_Add
(
v
,
w
);
}
Py_DECREF
(
v
);
...
...
@@ -1148,20 +1137,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
case
BINARY_SUBTRACT
:
w
=
POP
();
v
=
TOP
();
if
(
PyInt_CheckExact
(
v
)
&&
PyInt_CheckExact
(
w
))
{
/* INLINE: int - int */
register
long
a
,
b
,
i
;
a
=
PyLong_AS_LONG
(
v
);
b
=
PyLong_AS_LONG
(
w
);
i
=
a
-
b
;
if
((
i
^
a
)
<
0
&&
(
i
^~
b
)
<
0
)
goto
slow_sub
;
x
=
PyLong_FromLong
(
i
);
}
else
{
slow_sub:
x
=
PyNumber_Subtract
(
v
,
w
);
}
x
=
PyNumber_Subtract
(
v
,
w
);
Py_DECREF
(
v
);
Py_DECREF
(
w
);
SET_TOP
(
x
);
...
...
@@ -1171,21 +1147,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
case
BINARY_SUBSCR
:
w
=
POP
();
v
=
TOP
();
if
(
PyList_CheckExact
(
v
)
&&
PyInt_CheckExact
(
w
))
{
/* INLINE: list[int] */
Py_ssize_t
i
=
PyLong_AsSsize_t
(
w
);
if
(
i
<
0
)
i
+=
PyList_GET_SIZE
(
v
);
if
(
i
>=
0
&&
i
<
PyList_GET_SIZE
(
v
))
{
x
=
PyList_GET_ITEM
(
v
,
i
);
Py_INCREF
(
x
);
}
else
goto
slow_get
;
}
else
slow_get:
x
=
PyObject_GetItem
(
v
,
w
);
x
=
PyObject_GetItem
(
v
,
w
);
Py_DECREF
(
v
);
Py_DECREF
(
w
);
SET_TOP
(
x
);
...
...
@@ -1319,24 +1281,13 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
case
INPLACE_ADD
:
w
=
POP
();
v
=
TOP
();
if
(
PyInt_CheckExact
(
v
)
&&
PyInt_CheckExact
(
w
))
{
/* INLINE: int + int */
register
long
a
,
b
,
i
;
a
=
PyLong_AS_LONG
(
v
);
b
=
PyLong_AS_LONG
(
w
);
i
=
a
+
b
;
if
((
i
^
a
)
<
0
&&
(
i
^
b
)
<
0
)
goto
slow_iadd
;
x
=
PyLong_FromLong
(
i
);
}
else
if
(
PyUnicode_CheckExact
(
v
)
&&
if
(
PyUnicode_CheckExact
(
v
)
&&
PyUnicode_CheckExact
(
w
))
{
x
=
unicode_concatenate
(
v
,
w
,
f
,
next_instr
);
/* unicode_concatenate consumed the ref to v */
goto
skip_decref_v
;
}
else
{
slow_iadd:
x
=
PyNumber_InPlaceAdd
(
v
,
w
);
}
Py_DECREF
(
v
);
...
...
@@ -1349,20 +1300,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
case
INPLACE_SUBTRACT
:
w
=
POP
();
v
=
TOP
();
if
(
PyInt_CheckExact
(
v
)
&&
PyInt_CheckExact
(
w
))
{
/* INLINE: int - int */
register
long
a
,
b
,
i
;
a
=
PyLong_AS_LONG
(
v
);
b
=
PyLong_AS_LONG
(
w
);
i
=
a
-
b
;
if
((
i
^
a
)
<
0
&&
(
i
^~
b
)
<
0
)
goto
slow_isub
;
x
=
PyLong_FromLong
(
i
);
}
else
{
slow_isub:
x
=
PyNumber_InPlaceSubtract
(
v
,
w
);
}
x
=
PyNumber_InPlaceSubtract
(
v
,
w
);
Py_DECREF
(
v
);
Py_DECREF
(
w
);
SET_TOP
(
x
);
...
...
@@ -1865,30 +1803,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
case
COMPARE_OP
:
w
=
POP
();
v
=
TOP
();
if
(
PyInt_CheckExact
(
w
)
&&
PyInt_CheckExact
(
v
))
{
/* INLINE: cmp(int, int) */
register
long
a
,
b
;
register
int
res
;
a
=
PyLong_AS_LONG
(
v
);
b
=
PyLong_AS_LONG
(
w
);
switch
(
oparg
)
{
case
PyCmp_LT
:
res
=
a
<
b
;
break
;
case
PyCmp_LE
:
res
=
a
<=
b
;
break
;
case
PyCmp_EQ
:
res
=
a
==
b
;
break
;
case
PyCmp_NE
:
res
=
a
!=
b
;
break
;
case
PyCmp_GT
:
res
=
a
>
b
;
break
;
case
PyCmp_GE
:
res
=
a
>=
b
;
break
;
case
PyCmp_IS
:
res
=
v
==
w
;
break
;
case
PyCmp_IS_NOT
:
res
=
v
!=
w
;
break
;
default:
goto
slow_compare
;
}
x
=
res
?
Py_True
:
Py_False
;
Py_INCREF
(
x
);
}
else
{
slow_compare:
x
=
cmp_outcome
(
oparg
,
v
,
w
);
}
x
=
cmp_outcome
(
oparg
,
v
,
w
);
Py_DECREF
(
v
);
Py_DECREF
(
w
);
SET_TOP
(
x
);
...
...
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