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

Drop some useless allocations #2136

Merged
merged 5 commits into from
Aug 20, 2021
Merged

Drop some useless allocations #2136

merged 5 commits into from
Aug 20, 2021

Commits on Aug 20, 2021

  1. io: don't allocate new error on every call to Bytes()

    It makes no sense and we're using Bytes() pretty often.
    roman-khimov committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    b8dd284 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    abc4822 View commit details
    Browse the repository at this point in the history
  3. core: simplify and correct notification handling

     * both 'to' and 'from' are either Null or Hash160, there is no other
       possibility for valid NEP-17. So returning util.Uint160{} in case of
       parsing error is wrong.
     * but this is what allowed burns/mints to work at the expense of error
       allocation inside of util.Uint160DecodeBytesBE()
     * Uint160 can technically fit into regular VM integer, so even though it'd be
       quite surprising to see it there, TryBytes() is more correct (and easier!)
       to use
     * same thing with `amount`, we have `TryInteger()` that easily covers all
       possible cases and does appropriate error checking inside
    roman-khimov committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    a68a8aa View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    2e39f1a View commit details
    Browse the repository at this point in the history
  5. interop: don't allocate for Functions and Notifications in New

    Functions are usually immediately replaced (and it's OK for them to be nil,
    searching through an array with length of zero is fine), Notifications are
    usually appended to (and are absolutely useless in verification contexts).
    roman-khimov committed Aug 20, 2021
    Configuration menu
    Copy the full SHA
    2808f68 View commit details
    Browse the repository at this point in the history