Skip to content

Commit

Permalink
README.md: avoid []byte -> string allocation/copy (#98)
Browse files Browse the repository at this point in the history
FreeCache invests a lot of effort to minimize GC overhead, yet the README example has a case where a (potentially very large) copy is made just as part of a `fmt.Println` call. With this change, it uses `fmt.Printf("%s\n", ...)`, which should be used in any case involving `Println` and a `[]byte` that's intended to be interpreted as string data.
  • Loading branch information
extemporalgenome authored Mar 27, 2021
1 parent a308261 commit 6e76df7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ got, err := cache.Get(key)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(string(got))
fmt.Printf("%s\n", got)
}
affected := cache.Del(key)
fmt.Println("deleted key ", affected)
Expand Down

0 comments on commit 6e76df7

Please sign in to comment.