Skip to content

Commit

Permalink
regexp: deleted (some) firstbyte stupidness
Browse files Browse the repository at this point in the history
Change-Id: I13edfcb8ab376cafcdd930142cd2cd256b3de22f
  • Loading branch information
matloob committed Apr 21, 2016
1 parent 11a33f2 commit 1501bee
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions internal/dfa/dfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ func (d *DFA) analyzeSearch(params *searchParams) bool {

params.start = info.start
params.firstbyte = atomic.LoadInt64(&info.firstbyte)
if params.firstbyte >= 0 {
DebugPrintf("hasfirstbyte\n")
}

return true
}
Expand Down Expand Up @@ -185,25 +188,12 @@ func (d *DFA) analyzeSearchHelper(params *searchParams, info *startInfo, flags f
return true
}

// Try to find a byte going out by looking through runes < 256
// TODO(matloob): we don't actually use firstbyte. fix that!
firstByte := fbNone
for r := rune(0); r < 256; r++ {
s := d.runStateOnRune(info.start, r)
if s == nil {
// Synchronize with "quick check" above.
atomic.StoreInt64(&info.firstbyte, fbNone)
return false
}
if s == info.start {
continue
}
if firstByte == fbNone {
firstByte = int64(r) // ... first one
} else {
firstByte = fbMany // ... too many
break
}
}

if d.prefixer != nil && d.prefixer.Prefix() != "" {
firstByte = 'a' // dummy for now
}

// Synchronize with "quick check" above.
atomic.StoreInt64(&info.firstbyte, firstByte)
Expand Down

0 comments on commit 1501bee

Please sign in to comment.