yuja added a comment.

  > +/* Convert a PyInt or PyLong to a long. Returns false if there is an
  >  +   error, in which case an exception will already have been set. */
  >  +static inline bool pylong_to_long(PyObject *pylong, long *out)
  
  Nit: I prefer 0/-1 return value instead of bool since that's the convention
  of CPython API.
  
  > +   *out = PyLong_AsLong(pylong);
  >  +  return PyErr_Occurred() == NULL;
  
  Perhaps, checking `*out != -1` can be a fast path, though I don't know how
  much we care about the performance here.
  
  >   static int rustla_contains(rustlazyancestorsObject *self, PyObject *rev)
  >   {
  > 
  > - if (!(PyInt_Check(rev))) { +      long lrev; +    if 
(!pylong_to_long(rev, &lrev)) {              return 0;
  
  Needs `PyErr_Clear() since `non_int in self` isn't an error.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5235

To: durin42, #hg-reviewers
Cc: yuja, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to