From 6e76df70d7ca0ede26075d97cb7f28bc4f24f130 Mon Sep 17 00:00:00 2001 From: Kevin Gillette Date: Fri, 26 Mar 2021 20:21:35 -0600 Subject: [PATCH] README.md: avoid []byte -> string allocation/copy (#98) 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. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ceb354a..e68b2c3 100644 --- a/README.md +++ b/README.md @@ -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)