From adf5320df4676326c2f2612c2168c2113a7e6540 Mon Sep 17 00:00:00 2001 From: Ilan Pillemer Date: Thu, 21 Jul 2022 08:39:21 +0100 Subject: [PATCH] strings.Builder instead of bytes.Buffer (#285) --- fsnotify.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fsnotify.go b/fsnotify.go index b474b52..3fbc792 100644 --- a/fsnotify.go +++ b/fsnotify.go @@ -9,9 +9,9 @@ package fsnotify import ( - "bytes" "errors" "fmt" + "strings" ) // Event represents a single file system notification. @@ -33,28 +33,28 @@ const ( ) func (op Op) String() string { - // Use a buffer for efficient string concatenation - var buffer bytes.Buffer + // Use a builder for efficient string concatenation + var builder strings.Builder if op&Create == Create { - buffer.WriteString("|CREATE") + builder.WriteString("|CREATE") } if op&Remove == Remove { - buffer.WriteString("|REMOVE") + builder.WriteString("|REMOVE") } if op&Write == Write { - buffer.WriteString("|WRITE") + builder.WriteString("|WRITE") } if op&Rename == Rename { - buffer.WriteString("|RENAME") + builder.WriteString("|RENAME") } if op&Chmod == Chmod { - buffer.WriteString("|CHMOD") + builder.WriteString("|CHMOD") } - if buffer.Len() == 0 { + if builder.Len() == 0 { return "" } - return buffer.String()[1:] // Strip leading pipe + return builder.String()[1:] // Strip leading pipe } // String returns a string representation of the event in the form -- 2.50.1