chiark / gitweb /
algorithms.c: Reformat some of the `keysz' code.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 29 Jul 2017 00:10:52 +0000 (01:10 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 10 Nov 2018 01:30:58 +0000 (01:30 +0000)
Nothing major.  Remove the separate check that max >= 0 since it's
implied by 0 <= min <= dfl <= max.

algorithms.c

index 0f05f75f9a6db348e467479dd953492668132160..e55456ea605771c1f1ac87ee19821dde6489bdc2 100644 (file)
@@ -107,11 +107,9 @@ static PyObject *keyszrange_pynew(PyTypeObject *ty,
   if (!PyArg_ParseTupleAndKeywords(arg, kw, "i|iii:new", kwlist,
                                   &dfl, &min, &max, &mod))
     goto end;
-  if (dfl < 0 || min < 0 || max < 0)
-    VALERR("key size cannot be negative");
-  if (min > dfl || (max && dfl > max))
-    VALERR("bad key size bounds");
-  if (mod <= 0 || dfl % mod || min % mod || max % mod)
+  if (dfl < 0 || min < 0) VALERR("key size cannot be negative");
+  if (min > dfl || (max && dfl > max)) VALERR("bad key size bounds");
+  if (mod <= 0 || dfl%mod || min%mod || max%mod)
     VALERR("bad key size modulus");
   o = (keyszrange_pyobj *)ty->tp_alloc(ty, 0);
   o->dfl = dfl;
@@ -132,8 +130,7 @@ static PyObject *keyszset_pynew(PyTypeObject *ty,
   PyObject *x = 0, *l = 0;
   keyszset_pyobj *o = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "i|O:new", kwlist,
-                                         &dfl, &set))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "i|O:new", kwlist, &dfl, &set))
     goto end;
   if (!set) set = PyTuple_New(0);
   else Py_INCREF(set);