-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chore(vm): optimize code style #6552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -367,20 +367,18 @@ public static long getVoteWitnessCost(Program program) { | |
| public static long getVoteWitnessCost2(Program program) { | ||
| Stack stack = program.getStack(); | ||
| long oldMemSize = program.getMemSize(); | ||
| DataWord amountArrayLength = stack.get(stack.size() - 1).clone(); | ||
| DataWord amountArrayOffset = stack.get(stack.size() - 2); | ||
| DataWord witnessArrayLength = stack.get(stack.size() - 3).clone(); | ||
| DataWord witnessArrayOffset = stack.get(stack.size() - 4); | ||
| BigInteger amountArrayLength = stack.get(stack.size() - 1).value(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inlining I also think this PR need more relavant details for review. |
||
| BigInteger amountArrayOffset = stack.get(stack.size() - 2).value(); | ||
| BigInteger witnessArrayLength = stack.get(stack.size() - 3).value(); | ||
| BigInteger witnessArrayOffset = stack.get(stack.size() - 4).value(); | ||
|
|
||
| DataWord wordSize = new DataWord(DataWord.WORD_SIZE); | ||
| BigInteger wordSize = BigInteger.valueOf(DataWord.WORD_SIZE); | ||
|
|
||
| amountArrayLength.mul(wordSize); | ||
| amountArrayLength.add(wordSize); // dynamic array length is at least 32 bytes | ||
| BigInteger amountArrayMemoryNeeded = memNeeded(amountArrayOffset, amountArrayLength); | ||
| BigInteger amountArrayMemoryNeeded = | ||
| amountArrayLength.multiply(wordSize).add(wordSize).add(amountArrayOffset); | ||
|
|
||
| witnessArrayLength.mul(wordSize); | ||
| witnessArrayLength.add(wordSize); // dynamic array length is at least 32 bytes | ||
| BigInteger witnessArrayMemoryNeeded = memNeeded(witnessArrayOffset, witnessArrayLength); | ||
| BigInteger witnessArrayMemoryNeeded = | ||
| witnessArrayLength.multiply(wordSize).add(wordSize).add(witnessArrayOffset); | ||
|
|
||
| return VOTE_WITNESS + calcMemEnergy(oldMemSize, | ||
| (amountArrayMemoryNeeded.compareTo(witnessArrayMemoryNeeded) > 0 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it was changed from DataWord to BigInteger;
And the PR title doesn't match the code format modifications, so relevant details should be supplemented.