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

use unsafeBytesToString to reuse memory #1434

Open
wants to merge 1 commit into
base: release-branch.v7
Choose a base branch
from

Conversation

yjhmelody
Copy link

@yjhmelody yjhmelody commented Nov 18, 2020

I found that some operations are very expensive about mem alloc when string(bytes).
Such as:

image

So I try to reuse some mems by using unsafe.

@mitar
Copy link

mitar commented Sep 16, 2022

Just for the record, this is done inside standard library as well: https://go.dev/src/strings/builder.go#L46

@mitar
Copy link

mitar commented Sep 16, 2022

Although there will be soon official public API to do this: golang/go#53003

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.

None yet

2 participants