Skip to content

Commit

Permalink
Remove lots of string literals
Browse files Browse the repository at this point in the history
Using strings in helper functions causes a lot of string-to-[]byte
allocations. This fix is centered around converging the tag() helper
func to the []byte lingo. In order to do that, a lot of string literals
have moved to global variables, where string to []byte conversion can
happen once.
  • Loading branch information
rtfb committed Sep 10, 2016
1 parent e0fc1a0 commit 31f2685
Showing 1 changed file with 163 additions and 58 deletions.
Loading

2 comments on commit 31f2685

@dmitshur
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rtfb This is good. I just want to make a comment that sometimes doing w.WriteString(str) can be as performant as w.Write(b), if you have a writer that efficiently implements WriteString method. Just FYI.

@dmitshur
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not applicable here since we take an io.Writer as input in the API.

Please sign in to comment.