@@ -18,7 +18,6 @@ import (
1818 "encoding/json"
1919 "reflect"
2020 "sort"
21- "sync"
2221)
2322
2423type (
@@ -35,10 +34,6 @@ type (
3534 // 3. Correlation map (TODO)
3635 Set struct {
3736 equivalent Distinct
38-
39- lock sync.Mutex
40- encoders [maxConcurrentEncoders ]EncoderID
41- encoded [maxConcurrentEncoders ]string
4237 }
4338
4439 // Distinct wraps a variable-size array of `KeyValue`,
7671 }
7772)
7873
79- const maxConcurrentEncoders = 3
80-
8174// EmptySet returns a reference to a Set with no elements.
8275//
8376// This is a convenience provided for optimized calling utility.
@@ -182,51 +175,13 @@ func (l *Set) Equals(o *Set) bool {
182175}
183176
184177// Encoded returns the encoded form of this set, according to
185- // `encoder`. The result will be cached in this `*Set`.
178+ // `encoder`.
186179func (l * Set ) Encoded (encoder Encoder ) string {
187180 if l == nil || encoder == nil {
188181 return ""
189182 }
190183
191- id := encoder .ID ()
192- if ! id .Valid () {
193- // Invalid IDs are not cached.
194- return encoder .Encode (l .Iter ())
195- }
196-
197- var lookup * string
198- l .lock .Lock ()
199- for idx := 0 ; idx < maxConcurrentEncoders ; idx ++ {
200- if l .encoders [idx ] == id {
201- lookup = & l .encoded [idx ]
202- break
203- }
204- }
205- l .lock .Unlock ()
206-
207- if lookup != nil {
208- return * lookup
209- }
210-
211- r := encoder .Encode (l .Iter ())
212-
213- l .lock .Lock ()
214- defer l .lock .Unlock ()
215-
216- for idx := 0 ; idx < maxConcurrentEncoders ; idx ++ {
217- if l .encoders [idx ] == id {
218- return l .encoded [idx ]
219- }
220- if ! l .encoders [idx ].Valid () {
221- l .encoders [idx ] = id
222- l .encoded [idx ] = r
223- return r
224- }
225- }
226-
227- // TODO: This is a performance cliff. Find a way for this to
228- // generate a warning.
229- return r
184+ return encoder .Encode (l .Iter ())
230185}
231186
232187func empty () Set {
@@ -246,7 +201,7 @@ func NewSet(kvs ...KeyValue) Set {
246201 return empty ()
247202 }
248203 s , _ := NewSetWithSortableFiltered (kvs , new (Sortable ), nil )
249- return s //nolint
204+ return s
250205}
251206
252207// NewSetWithSortable returns a new `Set`. See the documentation for
@@ -259,7 +214,7 @@ func NewSetWithSortable(kvs []KeyValue, tmp *Sortable) Set {
259214 return empty ()
260215 }
261216 s , _ := NewSetWithSortableFiltered (kvs , tmp , nil )
262- return s //nolint
217+ return s
263218}
264219
265220// NewSetWithFiltered returns a new `Set`. See the documentation for
0 commit comments