[WIP] Update linter config + speed optimizations

This commit is contained in:
eleksir
2025-11-23 16:41:20 +03:00
parent d9ce425981
commit 3f5704237a
14 changed files with 1267 additions and 475 deletions

View File

@@ -4,16 +4,18 @@ import (
"sync"
)
// Collection is sync.Map, that stores arbitrary data.
type Collection struct {
items sync.Map
close chan struct{}
}
type (
// Collection is sync.Map, that stores arbitrary data.
Collection struct {
close chan struct{}
items sync.Map
}
// Item just interface for stoing any data.
type item struct {
data any
}
// Item just interface for stoing any data.
item struct {
data any
}
)
// NewCollection creates new instance of "collection".
func NewCollection() *Collection {
@@ -44,7 +46,7 @@ func (collection *Collection) Set(key any, value any) {
})
}
// Range apply function f to all keys/values in collection. Retuns immediatly on first error.
// Range apply function f to all keys/values in collection. Returns immediately on first error.
func (collection *Collection) Range(f func(key, value any) bool) {
fn := func(key, value any) bool {
item := value.(item)
@@ -63,6 +65,7 @@ func (collection *Collection) Delete(key any) {
// Close frees memory occupied by collection and deletes collection itself.
func (collection *Collection) Close() {
collection.close <- struct{}{}
collection.items = sync.Map{}
}