Serhiy Storchaka added the comment:
Unsigned type can be used for more efficient checking on integer overflow.
new_allocated = (newsize >> 3) + (newsize < 9 ? 3 : 6);
new_allocated += (size_t)newsize;
if (new_allocated < (size_t)newsize) {
PyErr_NoMemory();
return -1;
}
Checking "new_allocated < (size_t)newsize" can be more efficient than
"new_allocated > PY_SSIZE_T_MAX - newsize".
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27660>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com