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

rlp: remove allocation of bytes.Reader in DecodeBytes #27987

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

fjl
Copy link
Contributor

@fjl fjl commented Aug 23, 2023

This removes a small allocation per DecodeBytes call. Performance impact of this change is hard to assess, but it will certainly not be slower than before.

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM.

There are several other places where we could do this, should we apply this same fix there too?

v4wire.go:

	s := rlp.NewStream(bytes.NewReader(sigdata[1:]), 0)

accessors_chain.go has several of this type:

	if err := rlp.Decode(bytes.NewReader(data), header); err != nil {

@holiman
Copy link
Contributor

holiman commented Aug 23, 2023

Hm, I guess the if err := rlp.Decode(bytes.NewReader(data), header); err != nil { -- example should be rewritten using DecodeBytes ?

@fjl fjl merged commit 5c7136a into ethereum:master Aug 23, 2023
@fjl fjl added this to the 1.13.0 milestone Aug 23, 2023
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants