Skip to content

Commit 7169992

Browse files
authored
Merge pull request ethereumjs#409 from ethereumjs/exp-simplify
Reorder EXP code to match other opcodes
2 parents f452ae9 + ef12ed5 commit 7169992

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/opFns.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,15 @@ module.exports = {
8888
}
8989
},
9090
EXP: function (base, exponent, runState) {
91-
var m = BN.red(utils.TWO_POW256)
92-
93-
base = base.toRed(m)
94-
95-
if (!exponent.isZero()) {
91+
if (exponent.isZero()) {
92+
return new BN(1)
93+
} else {
9694
var bytes = 1 + logTable(exponent)
9795
subGas(runState, new BN(bytes).muln(runState._common.param('gasPrices', 'expByte')))
96+
97+
var m = BN.red(utils.TWO_POW256)
98+
base = base.toRed(m)
9899
return base.redPow(exponent)
99-
} else {
100-
return new BN(1)
101100
}
102101
},
103102
SIGNEXTEND: function (k, val, runState) {

0 commit comments

Comments
 (0)