Skip to content
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

Remove obsolete code in decode.go #788

Conversation

fxamacker
Copy link
Member

@fxamacker fxamacker commented Apr 9, 2021

Closes #786

Description

Remove type assertions that immediately follow a function that returns the desired type.
Remove v1 compatibility code in v4 decodeBig.

Caveats

The modest speedup for decoding a 167 byte LinkValue was better than expected. Final performance comparisons for this week will be added to the text of #738 (identifying the master branch commit and hash of each Value data benchmarked).


For contributor use:

  • Targeted PR against feature/storage-optimizations branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

if err != nil {
return CapabilityValue{}, fmt.Errorf("invalid capability borrow type encoding: %w", err)
}

borrowType, ok = decodedStaticType.(StaticType)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering why this was here, decodeStaticTypealready returns aStaticTypeeven onmaster. I guess it used to return interface{}`. Nice cleanup 👍

Comment on lines -617 to -628
// The encoding of negative bignums is specified in
// https://tools.ietf.org/html/rfc7049#section-2.4.2:
// "For tag value 3, the value of the bignum is -1 - n."
//
// Negative bignums were encoded incorrectly in version < 2,
// as just -n.
//
// Fix this by adjusting by one.

if bigInt.Sign() < 0 && d.version < 2 {
bigInt.Add(&bigInt, bigOne)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@turbolent turbolent merged commit 430541d into onflow:feature/storage-optimizations Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants