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
42acb7b8
Commit
42acb7b8
authored
Sep 18, 2019
by
HongWeipeng
Committed by
Inada Naoki
Sep 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-35696: Simplify long_compare() (GH-16146)
parent
d299b8b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
Objects/longobject.c
Objects/longobject.c
+18
-18
No files found.
Objects/longobject.c
View file @
42acb7b8
...
...
@@ -3028,33 +3028,32 @@ PyLong_AsDouble(PyObject *v)
/* Methods */
static
int
/* if a < b, return a negative number
if a == b, return 0
if a > b, return a positive number */
static
Py_ssize_t
long_compare
(
PyLongObject
*
a
,
PyLongObject
*
b
)
{
Py_ssize_t
sign
;
if
(
Py_SIZE
(
a
)
!=
Py_SIZE
(
b
))
{
sign
=
Py_SIZE
(
a
)
-
Py_SIZE
(
b
);
}
else
{
Py_ssize_t
sign
=
Py_SIZE
(
a
)
-
Py_SIZE
(
b
);
if
(
sign
==
0
)
{
Py_ssize_t
i
=
Py_ABS
(
Py_SIZE
(
a
));
while
(
--
i
>=
0
&&
a
->
ob_digit
[
i
]
==
b
->
ob_digit
[
i
])
;
if
(
i
<
0
)
sign
=
0
;
else
{
sign
=
(
sdigit
)
a
->
ob_digit
[
i
]
-
(
sdigit
)
b
->
ob_digit
[
i
];
if
(
Py_SIZE
(
a
)
<
0
)
sign
=
-
sign
;
sdigit
diff
=
0
;
while
(
--
i
>=
0
)
{
diff
=
(
sdigit
)
a
->
ob_digit
[
i
]
-
(
sdigit
)
b
->
ob_digit
[
i
];
if
(
diff
)
{
break
;
}
}
sign
=
Py_SIZE
(
a
)
<
0
?
-
diff
:
diff
;
}
return
sign
<
0
?
-
1
:
sign
>
0
?
1
:
0
;
return
sign
;
}
static
PyObject
*
long_richcompare
(
PyObject
*
self
,
PyObject
*
other
,
int
op
)
{
in
t
result
;
Py_ssize_
t
result
;
CHECK_BINOP
(
self
,
other
);
if
(
self
==
other
)
result
=
0
;
...
...
@@ -5210,7 +5209,8 @@ _PyLong_DivmodNear(PyObject *a, PyObject *b)
{
PyLongObject
*
quo
=
NULL
,
*
rem
=
NULL
;
PyObject
*
twice_rem
,
*
result
,
*
temp
;
int
cmp
,
quo_is_odd
,
quo_is_neg
;
int
quo_is_odd
,
quo_is_neg
;
Py_ssize_t
cmp
;
/* Equivalent Python code:
...
...
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