]> granicus.if.org Git - python/commitdiff
_PyLong_Sign(): remove an assert that needed a variable ndigits that
authorGuido van Rossum <guido@python.org>
Mon, 3 Feb 2003 15:28:19 +0000 (15:28 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 3 Feb 2003 15:28:19 +0000 (15:28 +0000)
wasn't used outside the assert (and hence caused a compiler warning
about an unused variable in NDEBUG mode).  The assert wasn't very
useful any more.

_PyLong_NumBits(): moved the calculation of ndigits after asserting
that v != NULL.

Objects/longobject.c

index 2ccf414edb5f0052270cb66a3cb6618d1ffe7776..c2d6ea74a72a594063ef158498f289fe93aecf64 100644 (file)
@@ -264,11 +264,9 @@ int
 _PyLong_Sign(PyObject *vv)
 {
        PyLongObject *v = (PyLongObject *)vv;
-       const int ndigits = ABS(v->ob_size);
 
        assert(v != NULL);
        assert(PyLong_Check(v));
-       assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0);
 
        return v->ob_size == 0 ? 0 : (v->ob_size < 0 ? -1 : 1);
 }
@@ -278,10 +276,11 @@ _PyLong_NumBits(PyObject *vv)
 {
        PyLongObject *v = (PyLongObject *)vv;
        size_t result = 0;
-       int ndigits = ABS(v->ob_size);
+       int ndigits;
 
        assert(v != NULL);
        assert(PyLong_Check(v));
+       ndigits = ABS(v->ob_size);
        assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0);
        if (ndigits > 0) {
                digit msd = v->ob_digit[ndigits - 1];