Skip to content

Commit

Permalink
refactor: improve cohesion
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Nov 26, 2023
1 parent a67148b commit e57cfc8
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions pkg/symbol/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ import (
type (
// TableOptions holds options for configuring a Table.
TableOptions struct {
LoadHooks []LoadHook // LoadHooks define functions to be executed on symbol loading.
UnloadHooks []UnloadHook // UnloadHooks define functions to be executed on symbol unloading.
LoadHooks []LoadHook // LoadHooks define functions to be executed on symbol loading.
UnloadHooks []UnloadHook // UnloadHooks define functions to be executed on symbol unloading.
}

// Table manages the storage and operations for Symbols.
Table struct {
symbols map[ulid.ULID]*Symbol
unlinks map[ulid.ULID]map[string][]scheme.PortLocation
symbols map[ulid.ULID]*Symbol
unlinks map[ulid.ULID]map[string][]scheme.PortLocation
linked map[ulid.ULID]map[string][]scheme.PortLocation
index map[string]map[string]ulid.ULID
loadHooks []LoadHook
unloadHooks []UnloadHook
mu sync.RWMutex
loadHooks []LoadHook
unloadHooks []UnloadHook
mu sync.RWMutex
}
)

Expand Down Expand Up @@ -68,19 +68,18 @@ func (t *Table) Insert(sym *Symbol) error {
return err
}

Check warning on line 69 in pkg/symbol/table.go

View check run for this annotation

Codecov / codecov/patch

pkg/symbol/table.go#L68-L69

Added lines #L68 - L69 were not covered by tests
}
}

t.symbols[sym.ID()] = sym

if prev != nil && prev.Name() != "" {
if namespace, ok := t.index[prev.Namespace()]; ok {
delete(namespace, prev.Name())
if len(namespace) == 0 {
delete(t.index, prev.Namespace())
if prev.Name() != "" {
if namespace, ok := t.index[prev.Namespace()]; ok {
delete(namespace, prev.Name())
if len(namespace) == 0 {
delete(t.index, prev.Namespace())
}

Check warning on line 77 in pkg/symbol/table.go

View check run for this annotation

Codecov / codecov/patch

pkg/symbol/table.go#L73-L77

Added lines #L73 - L77 were not covered by tests
}
}
}

t.symbols[sym.ID()] = sym
t.index[sym.Namespace()] = lo.Assign(t.index[sym.Namespace()], map[string]ulid.ULID{sym.Name(): sym.ID()})

var deletions map[string][]scheme.PortLocation
Expand Down

0 comments on commit e57cfc8

Please sign in to comment.