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

encoding/gob: allocates underlying slice array even if already present #2275

Closed
griesemer opened this issue Sep 19, 2011 · 1 comment
Closed

encoding/gob: allocates underlying slice array even if already present #2275

griesemer opened this issue Sep 19, 2011 · 1 comment
Assignees

Comments

@griesemer
Copy link
Contributor

@griesemer griesemer commented Sep 19, 2011

In this code pattern:

d := data[i:j]
gob.NewDecoder(r).Decode(&d)

gob appears to allocate a new underlying array for d even though there is one present
already. Thus, for the data to be in data[i:j] it will need to be copied from d again:

copy(data[i:j], d)

Ideally, this should not be needed.
@robpike
Copy link
Contributor

@robpike robpike commented Sep 19, 2011

Comment 1:

This issue was closed by revision bf595ba.

Status changed to Fixed.

@mikioh mikioh changed the title gob allocates underlying slice array even if already present encoding/gob: allocates underlying slice array even if already present Feb 26, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.