...
Use loop predicate to remove array range checks in a loop.
original loop
|
|---|
for (int i = init, i < limit; i += stride) { // loop with array range check ... if (scale*i + offset < a.length) { // array range check <ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e242b0a48c870eab-b7df9170-4d0e47f9-aa6bbe75-9fea52996dac040297cef274"><ac:plain-text-body><![CDATA[ ... a[scale*i+offset] ... ]]></ac:plain-text-body></ac:structured-macro> } else raise_uncommon_trap(); ... } |
after loop predication
|
|---|
if ( scale * imax + offset < a.length ) { // loop predicate. imax is the maximum value of i where init <= i < limit for (int i = init, i < limit; i += stride) { // loop without array range check ... <ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="532b025ae15d953d-acd5a52d-4fff42c8-b74184ba-ed29c5eaba1938eb6db4b29d"><ac:plain-text-body><![CDATA[ ... a[scale*i+offset] ... ]]></ac:plain-text-body></ac:structured-macro> ... } } else raise_uncommon_trap();
|