bpo-35091: Objects/listobject.c: Don't rely on signed int overflow in… by izbyshev · Pull Request #10184 · python/cpython
| assert(lastofs <= ofs && ofs <= (size_t)n); | ||
| /* Now a[lastofs-1] < key <= a[ofs], so key belongs somewhere to the | ||
| * right of lastofs-1 but no farther right than ofs. Do a binary | ||
| * search, with invariant a[lastofs-1] < key <= a[ofs]. |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * search, with invariant a[lastofs-1] < key <= a[ofs]. | |
| * search, with invariant a[lastofs] < key <= a[ofs]. |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike the first part of the comment, the last line seems to refer to the invariant holding after ++lastofs, which I moved higher. Therefore, no correction is needed.
| assert(lastofs <= ofs && ofs <= (size_t)n); | ||
| /* Now a[lastofs-1] <= key < a[ofs], so key belongs somewhere to the | ||
| * right of lastofs-1 but no farther right than ofs. Do a binary | ||
| * search, with invariant a[lastofs-1] <= key < a[ofs]. |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * search, with invariant a[lastofs-1] <= key < a[ofs]. | |
| * search, with invariant a[lastofs] <= key < a[ofs]. |