summaryrefslogtreecommitdiff
path: root/Porting/bench.pl
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2016-08-17 12:06:27 +0100
committerDavid Mitchell <davem@iabyn.com>2016-08-17 13:39:24 +0100
commitf4d8be8b395cdacf05f8c461fb7e9ce0366ff56f (patch)
tree87ffdc5f105230dcea6446fcb2ea3da5852c0ee7 /Porting/bench.pl
parent11b62bc4c2460b23807b5c84c6e8b463068cf886 (diff)
downloadperl-f4d8be8b395cdacf05f8c461fb7e9ce0366ff56f.tar.gz
av_fetch(): use less branches.
The code that handles negative array indexes and out-of-bounds negative indices used to require: 2 conditions for a +ve index 3 conditions for a -ve index After this commit, for the common case where the index is in bounds, it requires a single condition regardless of sign. For the less common case of out-of-bounds, it requires 2 conditions. Also, the one condition is more branch-predict friendly - it's whether the index is in bounds or not. Previously the first test was whether key < 0, and in code that does mixed signs, such as $a[0] + $a[-1], branch prediction could be tricky. It achieves this at the expense of a more complex expression for the key.
Diffstat (limited to 'Porting/bench.pl')
0 files changed, 0 insertions, 0 deletions