Replaced rune-slice parameters with string parameters in functions; avoids unnecessary conversion from strings to rune-slices
This commit is contained in:
6
nfa.go
6
nfa.go
@@ -27,7 +27,7 @@ type State struct {
|
||||
|
||||
// Checks if the given state's assertion is true. Returns true if the given
|
||||
// state doesn't have an assertion.
|
||||
func (s State) checkAssertion(str []rune, idx int) bool {
|
||||
func (s State) checkAssertion(str string, idx int) bool {
|
||||
if s.assert == SOS {
|
||||
return idx == 0
|
||||
}
|
||||
@@ -44,7 +44,7 @@ func (s State) checkAssertion(str []rune, idx int) bool {
|
||||
}
|
||||
|
||||
// Returns true if the contents of 's' contain the value at the given index of the given string
|
||||
func (s State) contentContains(str []rune, idx int) bool {
|
||||
func (s State) contentContains(str string, idx int) bool {
|
||||
if s.assert != NONE {
|
||||
return s.checkAssertion(str, idx)
|
||||
}
|
||||
@@ -54,7 +54,7 @@ func (s State) contentContains(str []rune, idx int) bool {
|
||||
|
||||
// Returns the matches for the character at the given index of the given string.
|
||||
// Also returns the number of matches. Returns -1 if an assertion failed.
|
||||
func (s State) matchesFor(str []rune, idx int) ([]*State, int) {
|
||||
func (s State) matchesFor(str string, idx int) ([]*State, int) {
|
||||
// Assertions can be viewed as 'checks'. If the check fails, we return
|
||||
// an empty array and 0.
|
||||
// If it passes, we treat it like any other state, and return all the transitions.
|
||||
|
Reference in New Issue
Block a user