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

add Grow function #82

Merged
merged 3 commits into from Aug 7, 2023
Merged

add Grow function #82

merged 3 commits into from Aug 7, 2023

Conversation

elee1766
Copy link
Contributor

@elee1766 elee1766 commented Aug 5, 2023

When using jx.GetEncoder() with streams, i constantly need to add this snippet

	enc := jx.GetEncoder()
	if cap(enc.Bytes()) < 4096 {
		enc.SetBytes(make([]byte, 0, 4096))
	}

i actually appreciate giving the user control over the allocation here - but i thought borrowing the Grow function from bytes.Buffer might be more useful. then i could do

	enc := jx.GetEncoder()
	enc.Grow(4096)

which would be more efficient, and also is much easier to read / understand.

@codecov
Copy link

codecov bot commented Aug 6, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (d2a6a27) 100.00% compared to head (043c94a) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #82   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           43        43           
  Lines         3187      3193    +6     
=========================================
+ Hits          3187      3193    +6     
Files Changed Coverage Δ
enc.go 100.00% <100.00%> (ø)
w.go 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ernado
Copy link
Member

ernado commented Aug 6, 2023

LGTM, please update git commit messages

@ernado ernado merged commit 50bd6f0 into go-faster:main Aug 7, 2023
6 checks passed
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