Skip to content

perf: use strings.Builder in GoString - #111

Open
zedongh wants to merge 1 commit into
santhosh-tekuri:masterfrom
zedongh:feat-validation-error-stringify-use-bytes-buffer
Open

perf: use strings.Builder in GoString#111
zedongh wants to merge 1 commit into
santhosh-tekuri:masterfrom
zedongh:feat-validation-error-stringify-use-bytes-buffer

Conversation

@zedongh

@zedongh zedongh commented Mar 15, 2023

Copy link
Copy Markdown

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

@santhosh-tekuri

Copy link
Copy Markdown
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
Copy Markdown
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

zedongh commented Mar 15, 2023

Copy link
Copy Markdown
Author

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

zedongh commented Mar 15, 2023

Copy link
Copy Markdown
Author

also ensure gofmt and govet is done on file;

done

Comment thread errors.go
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.

2 participants