Message278355
The expression for testing that some index is in half-open range from 0 to limit can be written as
index >= 0 && index < limit
or as
(size_t)index < (size_t)limit
The latter form generates simpler machine code. This is idiomatic code, it is used in many C and C++ libraries (including C++ stdlib implementations). It already is used in CPython (in deque implementation).
Proposed patch rewrites index range checks in more efficient way. The patch was generated automatically by coccinelle script, and then manually cleaned up. |
|
Date |
User |
Action |
Args |
2016-10-09 12:32:06 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka |
2016-10-09 12:32:05 | serhiy.storchaka | set | messageid: <1476016325.64.0.828735989384.issue28397@psf.upfronthosting.co.za> |
2016-10-09 12:32:05 | serhiy.storchaka | link | issue28397 messages |
2016-10-09 12:32:05 | serhiy.storchaka | create | |
|