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

bytes: double call to tryGoByReslice in bytes.Buffer when writing #24550

Closed
jgimeno opened this issue Mar 27, 2018 · 2 comments
Closed

bytes: double call to tryGoByReslice in bytes.Buffer when writing #24550

jgimeno opened this issue Mar 27, 2018 · 2 comments

Comments

@jgimeno
Copy link

jgimeno commented Mar 27, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.10

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

What did you do?

Checking the Write and WriteString made me realize that we try to grow by reslicing first, but if it is not possible we call grow. But the grow function tries again to grow by reslice, making a second call to reslice. I think in this case it is not needed to call:

m, ok := b.tryGrowByReslice(len(p))

Is enough to call directly grow function.

What did you expect to see?

Call only grow function.

What did you see instead?

Double call to tryGrowByReslice.

@jgimeno
Copy link
Author

jgimeno commented Mar 27, 2018

I can work on removing this if needed.

@ALTree ALTree changed the title Double call to tryGoByReslice in bytes.Buffer when writing. bytes: double call to tryGoByReslice in bytes.Buffer when writing Mar 27, 2018
@ALTree ALTree added this to the Unplanned milestone Mar 27, 2018
@ianlancetaylor
Copy link
Contributor

This is intentional because of the current compiler's implementation of function inlining. See #17857 and https://golang.org/cl/42813.

@golang golang locked and limited conversation to collaborators Mar 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants