exthereum / abi

The Ethereum ABI Interface
MIT License
20 stars 22 forks source link

Make do_encode and do_decode eligible for Tail-Call Optimization #1

Closed tsutsu closed 6 years ago

tsutsu commented 6 years ago

Like with exthereum/evm#32, ABI.TypeEncoder.do_encode/2 and ABI.TypeDecoder.do_decode/2 are performing operations after the recursive self-call, and so can blow their stacks. This PR rephrases them into tail-call-with-accumulator style.

Bonus efficiency fix: instead of repeatedly joining binaries in do_encode/2, an iolist() is built and then baked into a binary at the end using :erlang.iolist_to_binary/1.

No visible behaviour changes. Tests pass.

tsutsu commented 6 years ago

Sure, will do.

tsutsu commented 6 years ago

Actually, I don't see a contributors list in the repo files anywhere; what did you mean for me to add myself to?

hayesgm commented 6 years ago

@tsutsu in mix.exs

tsutsu commented 6 years ago

Ah, do you mean the Hex package[:maintainers] field? I believe that's supposed to be the set of people who can merge PRs to the repo.