Merge pull request #1517 from ethcore/shr-opt

Optimizing/simplifying shr
This commit is contained in:
Nikolay Volf 2016-07-01 17:58:01 +04:00 committed by GitHub
commit 24a00eefb3
1 changed files with 10 additions and 6 deletions

View File

@ -1031,7 +1031,7 @@ macro_rules! construct_uint {
// shift // shift
for i in word_shift..$n_words { for i in word_shift..$n_words {
ret[i] += original[i - word_shift] << bit_shift; ret[i] = original[i - word_shift] << bit_shift;
} }
// carry // carry
if bit_shift > 0 { if bit_shift > 0 {
@ -1052,14 +1052,18 @@ macro_rules! construct_uint {
let word_shift = shift / 64; let word_shift = shift / 64;
let bit_shift = shift % 64; let bit_shift = shift % 64;
// shift
for i in word_shift..$n_words { for i in word_shift..$n_words {
// Shift ret[i - word_shift] = original[i] >> bit_shift;
ret[i - word_shift] += original[i] >> bit_shift; }
// Carry
if bit_shift > 0 && i < $n_words - 1 { // Carry
ret[i - word_shift] += original[i + 1] << (64 - bit_shift); if bit_shift > 0 {
for i in word_shift+1..$n_words {
ret[i - word_shift - 1] += original[i] << (64 - bit_shift);
} }
} }
$name(ret) $name(ret)
} }
} }