Skip to content

Commit a54a4e4

Browse files
committed
ACTUALLY moved declarations to the tops of blocks
1 parent a12d784 commit a54a4e4

1 file changed

Lines changed: 51 additions & 48 deletions

File tree

Objects/listobject.c

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,18 +1942,20 @@ safe_object_compare(PyObject* v, PyObject* w, MergeState* ms)
19421942
static int
19431943
unsafe_object_compare(PyObject* v, PyObject* w, MergeState* ms)
19441944
{
1945-
/* Modified from Objects/object.c:PyObject_RichCompareBool, assuming: */
1946-
#ifdef Py_DEBUG
1947-
assert(v->ob_type == w->ob_type &&
1948-
v->ob_type->tp_richcompare != NULL);
1949-
#endif
1950-
int ok;
1945+
int ok; PyObject* res;
1946+
1947+
/* Modified from Objects/object.c:PyObject_RichCompareBool, assuming: */
1948+
#ifdef Py_DEBUG
1949+
assert(v->ob_type == w->ob_type &&
1950+
v->ob_type->tp_richcompare != NULL);
1951+
#endif
1952+
19511953

19521954
if (v == w) return 0;
19531955
if (v->ob_type->tp_richcompare != ms->key_richcompare)
19541956
return PyObject_RichCompareBool(v, w, Py_LT);
19551957

1956-
PyObject* res = (*(ms->key_richcompare))(v, w, Py_LT);
1958+
res = (*(ms->key_richcompare))(v, w, Py_LT);
19571959

19581960
if (res == Py_NotImplemented) {
19591961
Py_DECREF(res);
@@ -1975,16 +1977,18 @@ unsafe_object_compare(PyObject* v, PyObject* w, MergeState* ms)
19751977
/* Latin string compare: safe for any two latin (one byte per char) strings. */
19761978
static int
19771979
unsafe_latin_compare(PyObject* v, PyObject* w, MergeState* ms){
1978-
/* Modified from Objects/unicodeobject.c:unicode_compare, assuming: */
1979-
#ifdef Py_DEBUG
1980-
assert(v->ob_type == w->ob_type &&
1981-
v->ob_type == &PyUnicode_Type &&
1982-
PyUnicode_KIND(v) == PyUnicode_KIND(w) &&
1983-
PyUnicode_KIND(v) == PyUnicode_1BYTE_KIND);
1984-
#endif
1980+
int len, res;
1981+
1982+
/* Modified from Objects/unicodeobject.c:unicode_compare, assuming: */
1983+
#ifdef Py_DEBUG
1984+
assert(v->ob_type == w->ob_type &&
1985+
v->ob_type == &PyUnicode_Type &&
1986+
PyUnicode_KIND(v) == PyUnicode_KIND(w) &&
1987+
PyUnicode_KIND(v) == PyUnicode_1BYTE_KIND);
1988+
#endif
19851989

1986-
int len = Py_MIN(PyUnicode_GET_LENGTH(v), PyUnicode_GET_LENGTH(w));
1987-
int res = memcmp(PyUnicode_DATA(v), PyUnicode_DATA(w), len);
1990+
len = Py_MIN(PyUnicode_GET_LENGTH(v), PyUnicode_GET_LENGTH(w));
1991+
res = memcmp(PyUnicode_DATA(v), PyUnicode_DATA(w), len);
19881992

19891993
return (res != 0 ?
19901994
res < 0 :
@@ -1995,20 +1999,21 @@ unsafe_latin_compare(PyObject* v, PyObject* w, MergeState* ms){
19951999
static int
19962000
unsafe_long_compare(PyObject *v, PyObject *w, MergeState* ms)
19972001
{
1998-
/* Modified from Objects/longobject.c:long_compare, assuming: */
1999-
#ifdef Py_DEBUG
2000-
assert(v->ob_type == w->ob_type &&
2001-
v->ob_type == &PyLong_Type &&
2002-
Py_ABS(Py_SIZE(v)) <= 1 &&
2003-
Py_ABS(Py_SIZE(w)) <= 1);
2004-
#endif
2002+
PyLongObject *vl, *wl; sdigit v0, w0;
2003+
2004+
/* Modified from Objects/longobject.c:long_compare, assuming: */
2005+
#ifdef Py_DEBUG
2006+
assert(v->ob_type == w->ob_type &&
2007+
v->ob_type == &PyLong_Type &&
2008+
Py_ABS(Py_SIZE(v)) <= 1 &&
2009+
Py_ABS(Py_SIZE(w)) <= 1);
2010+
#endif
20052011

2006-
PyLongObject *vl, *wl;
20072012
vl = (PyLongObject*)v;
20082013
wl = (PyLongObject*)w;
20092014

2010-
sdigit v0 = Py_SIZE(vl) == 0 ? 0 : (sdigit)vl->ob_digit[0];
2011-
sdigit w0 = Py_SIZE(wl) == 0 ? 0 : (sdigit)wl->ob_digit[0];
2015+
v0 = Py_SIZE(vl) == 0 ? 0 : (sdigit)vl->ob_digit[0];
2016+
w0 = Py_SIZE(wl) == 0 ? 0 : (sdigit)wl->ob_digit[0];
20122017

20132018
if (Py_SIZE(vl) < 0)
20142019
v0 = -v0;
@@ -2021,13 +2026,13 @@ unsafe_long_compare(PyObject *v, PyObject *w, MergeState* ms)
20212026
/* Float compare: compare any two floats. */
20222027
static int
20232028
unsafe_float_compare(PyObject *v, PyObject *w, MergeState* ms){
2024-
/* Modified from Objects/floatobject.c:float_richcompare, assuming: */
2025-
#ifdef Py_DEBUG
2026-
assert(v->ob_type == w->ob_type &&
2027-
v->ob_type == &PyFloat_Type);
2028-
#endif
2029-
if (v == w) return 0;
2030-
2029+
/* Modified from Objects/floatobject.c:float_richcompare, assuming: */
2030+
#ifdef Py_DEBUG
2031+
assert(v->ob_type == w->ob_type &&
2032+
v->ob_type == &PyFloat_Type);
2033+
#endif
2034+
2035+
if (v == w) return 0;
20312036
return PyFloat_AS_DOUBLE(v) < PyFloat_AS_DOUBLE(w);
20322037
}
20332038

@@ -2038,25 +2043,23 @@ unsafe_float_compare(PyObject *v, PyObject *w, MergeState* ms){
20382043
* on two levels (as long as [x[0] for x in L] is type-homogeneous.) */
20392044
static int
20402045
unsafe_tuple_compare(PyObject* v, PyObject* w, MergeState* ms)
2041-
{
2042-
/* Modified from Objects/tupleobject.c:tuplerichcompare, assuming: */
2043-
#ifdef Py_DEBUG
2044-
assert(v->ob_type == w->ob_type &&
2045-
v->ob_type == &PyTuple_Type &&
2046-
Py_SIZE(v) > 0 &&
2047-
Py_SIZE(w) > 0);
2048-
#endif
2049-
2046+
{
20502047
PyTupleObject *vt, *wt;
2051-
Py_ssize_t i;
2052-
Py_ssize_t vlen, wlen;
2048+
Py_ssize_t i, vlen, wlen;
2049+
int k;
2050+
2051+
/* Modified from Objects/tupleobject.c:tuplerichcompare, assuming: */
2052+
#ifdef Py_DEBUG
2053+
assert(v->ob_type == w->ob_type &&
2054+
v->ob_type == &PyTuple_Type &&
2055+
Py_SIZE(v) > 0 &&
2056+
Py_SIZE(w) > 0);
2057+
#endif
2058+
2059+
if (v == w) return 0;
20532060

20542061
vt = (PyTupleObject *)v;
20552062
wt = (PyTupleObject *)w;
2056-
2057-
int k;
2058-
2059-
if (v == w) return 0;
20602063

20612064
/* Is v[0] < w[0]? */
20622065
k = (*(ms->tuple_elem_compare))(vt->ob_item[0], wt->ob_item[0], ms);

0 commit comments

Comments
 (0)