From 7356ee91ffe170615bff9654804b73e2fcada286 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 5 Oct 2022 11:19:19 +0300 Subject: [PATCH] [#1837] services/object: Optimize `uniqueIDWriter` Avoid encoding object ID to string. Signed-off-by: Evgenii Stratonikov --- pkg/services/object/search/util.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/services/object/search/util.go b/pkg/services/object/search/util.go index 411f0db92..e32dcb2f1 100644 --- a/pkg/services/object/search/util.go +++ b/pkg/services/object/search/util.go @@ -17,7 +17,7 @@ import ( type uniqueIDWriter struct { mtx sync.Mutex - written map[string]struct{} + written map[oid.ID]struct{} writer IDListWriter } @@ -44,7 +44,7 @@ type nmSrcWrapper struct { func newUniqueAddressWriter(w IDListWriter) IDListWriter { return &uniqueIDWriter{ - written: make(map[string]struct{}), + written: make(map[oid.ID]struct{}), writer: w, } } @@ -53,13 +53,9 @@ func (w *uniqueIDWriter) WriteIDs(list []oid.ID) error { w.mtx.Lock() for i := 0; i < len(list); i++ { // don't use range, slice mutates in body - s := list[i].EncodeToString() - // standard stringer is quite costly, it is better - // to facilitate the calculation of the key - - if _, ok := w.written[s]; !ok { + if _, ok := w.written[list[i]]; !ok { // mark address as processed - w.written[s] = struct{}{} + w.written[list[i]] = struct{}{} continue }