Skip to content

Commit

Permalink
use struct{} for WordPrefixMap to save a little memory
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Dec 22, 2023
1 parent 7811d93 commit f880d62
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions idx_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"unicode/utf8"
)

type WordPrefixMap map[rune]map[int]bool
type WordPrefixMap map[rune]map[int]struct{}

func (wpm WordPrefixMap) Add(term string, termIndex int) {
for _, word := range strings.Split(strings.ToLower(term), " ") {
Expand All @@ -23,9 +23,9 @@ func (wpm WordPrefixMap) Add(term string, termIndex int) {
}
m, ok := wpm[prefix]
if !ok {
m = map[int]bool{}
m = map[int]struct{}{}
wpm[prefix] = m
}
m[termIndex] = true
m[termIndex] = struct{}{}
}
}

0 comments on commit f880d62

Please # to comment.