Skip to content

Commit 37df513

Browse files
committed
Merge pull request #6 from SlyMarbo/master
Should give a reasonable performance boost when New is called with a large dictionary.
2 parents 45480ed + 16b6c48 commit 37df513

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ferret.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ func (SW *sortWrapper) Less(i, j int) bool {
8181

8282
// Creates an inverted suffix from a dictionary of byte arrays, mapping data, and a string->[]byte converter
8383
func New(Words, Results []string, Data []interface{}, Converter func(string) []byte) *InvertedSuffix {
84-
WordIndex := make([]int, 0)
85-
SuffixIndex := make([]int, 0)
86-
NewWords := make([][]byte, 0)
84+
WordIndex := make([]int, 0, len(Words))
85+
SuffixIndex := make([]int, 0, len(Words))
86+
NewWords := make([][]byte, 0, len(Words))
8787
for i, Word := range Words {
8888
word := Converter(Word)
8989
for j := 0; j < len(word); j++ {

0 commit comments

Comments
 (0)