This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients serhiy.storchaka
Date 2016-10-09.12:32:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1476016325.64.0.828735989384.issue28397@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-10-09 12:32:06serhiy.storchakasetrecipients: + serhiy.storchaka
2016-10-09 12:32:05serhiy.storchakasetmessageid: <1476016325.64.0.828735989384.issue28397@psf.upfronthosting.co.za>
2016-10-09 12:32:05serhiy.storchakalinkissue28397 messages
2016-10-09 12:32:05serhiy.storchakacreate