Skip to content

Commit

Permalink
comments about speed
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed May 20, 2020
1 parent 2c01dc2 commit dc2ce52
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions string/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,15 @@ func IndexAllIgnoreCaseUnicode(haystack string, needle string, limit int) [][]in
}
__permuteCacheLock.Unlock()

// TODO - Investigate
// This is using IndexAll in a loop which was faster than
// any implementation of Aho-Corasick or Boyer-Moore I tried
// but in theory Aho-Corasick / Rabin-Karp or even a modified
// version of Boyer-Moore should be faster than this
// version of Boyer-Moore should be faster than this.
// Especially since they should be able to do multiple comparisons
// at the same time.
// However after some investigation it turns out that this turns
// into a fancy vector instruction on AMD64 (which is all we care about)
// and as such its pretty hard to beat.
for _, term := range searchTerms {
locs = append(locs, IndexAll(haystack, term, limit)...)

Expand All @@ -173,11 +177,15 @@ func IndexAllIgnoreCaseUnicode(haystack string, needle string, limit int) [][]in
}
__permuteCacheLock.Unlock()

// TODO - Investigate
// This is using IndexAll in a loop which was faster than
// any implementation of Aho-Corasick or Boyer-Moore I tried
// but in theory Aho-Corasick / Rabin-Karp or even a modified
// version of Boyer-Moore should be faster than this
// version of Boyer-Moore should be faster than this.
// Especially since they should be able to do multiple comparisons
// at the same time.
// However after some investigation it turns out that this turns
// into a fancy vector instruction on AMD64 (which is all we care about)
// and as such its pretty hard to beat.
for _, term := range searchTerms {
potentialMatches := IndexAll(haystack, term, -1)

Expand Down

0 comments on commit dc2ce52

Please sign in to comment.