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

perf: use strings.Builder in GoString #111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zedongh
Copy link

@zedongh zedongh commented Mar 15, 2023

for large json validation may cause mess validation error, string concat cause poor performance, use byte.Buffer much better

@santhosh-tekuri
Copy link
Owner

please make following changes:

  • use strings.Builder for better performance; see here
  • change commit msg to perf: use strings.Builder in GoString
  • rename writeIntoBuffer to goStringTo
  • rename msgBuf to tgt
  • move new method to after GoString method
  • use loop to print indent; using strings.Repeat creates heap alloc which immediately discarded
  • replace WriteRune('\n') with WriteByte('\n')

@santhosh-tekuri
Copy link
Owner

also ensure gofmt and govet is done on file;

@zedongh zedongh force-pushed the feat-validation-error-stringify-use-bytes-buffer branch from 411cefa to e8d5a6f Compare March 15, 2023 13:34
@zedongh zedongh changed the title feat: using bytes.Buffer write string for ValidationError perf: use strings.Builder in GoString Mar 15, 2023
@zedongh
Copy link
Author

zedongh commented Mar 15, 2023

please make following changes:

  • use strings.Builder for better performance; see here
  • change commit msg to perf: use strings.Builder in GoString
  • rename writeIntoBuffer to goStringTo
  • rename msgBuf to tgt
  • move new method to after GoString method
  • use loop to print indent; using strings.Repeat creates heap alloc which immediately discarded
  • replace WriteRune('\n') with WriteByte('\n')

done

@zedongh
Copy link
Author

zedongh commented Mar 15, 2023

also ensure gofmt and govet is done on file;

done

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