From cdfc1f7b70274e59a14a32d8e19f34bab4d50772 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Mon, 4 Dec 2023 16:22:49 +0200 Subject: [PATCH] removed unnecessary Close call and formatted map hints --- tools/filesystem/filesystem.go | 1 - tools/store/store.go | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/filesystem/filesystem.go b/tools/filesystem/filesystem.go index 5c601745..c6d022b2 100644 --- a/tools/filesystem/filesystem.go +++ b/tools/filesystem/filesystem.go @@ -425,7 +425,6 @@ func (s *System) CreateThumb(originalKey string, thumbKey, thumbSize string) err return decodeErr } - r.Close() var thumbImg *image.NRGBA if width == 0 || height == 0 { diff --git a/tools/store/store.go b/tools/store/store.go index d71d085f..9dd8c364 100644 --- a/tools/store/store.go +++ b/tools/store/store.go @@ -23,13 +23,14 @@ func (s *Store[T]) Reset(newData map[string]T) { s.mux.Lock() defer s.mux.Unlock() - var clone = make(map[string]T, len(newData)) - - for k, v := range newData { - clone[k] = v + if len(newData) > 0 { + s.data = make(map[string]T, len(newData)) + for k, v := range newData { + s.data[k] = v + } + } else { + s.data = make(map[string]T) } - - s.data = clone } // Length returns the current number of elements in the store.