Minor code simplifications
Change-Id: Ieea5e4b363cd460a722358bbd9f5083ef09f657f
diff --git a/matrix.go b/matrix.go
index ecb22be..a36dfbb 100644
--- a/matrix.go
+++ b/matrix.go
@@ -479,21 +479,8 @@
// Transition was successful
rewindBuffer = false
- // Transition consumes a character
- if a != mat.epsilon {
-
- buffc++
-
- // Transition does not produce a character
- if buffc-bufft == 1 && (t&FIRSTBIT) != 0 {
- if DEBUG {
- log.Println("Nontoken forward", showBufferNew(buffer, bufft, buffc, buffi))
- }
- bufft++
- // rewindBuffer = true
- }
-
- } else {
+ // Transition consumes no character
+ if a == mat.epsilon {
// Transition marks the end of a token - so flush the buffer
if buffc-bufft > 0 {
if DEBUG {
@@ -507,6 +494,19 @@
sentenceEnd = true
w.SentenceEnd(buffc)
}
+
+ // Transition consumes a character
+ } else {
+ buffc++
+
+ // Transition does not produce a character
+ if buffc-bufft == 1 && (t&FIRSTBIT) != 0 {
+ if DEBUG {
+ log.Println("Nontoken forward", showBufferNew(buffer, bufft, buffc, buffi))
+ }
+ bufft++
+ // rewindBuffer = true
+ }
}
if eot {
@@ -526,11 +526,12 @@
log.Println("-> Rewind buffer", bufft, buffc, buffi, epsilonOffset)
}
- // TODO: Better as a ring buffer
- // buffer = buffer[buffc:] !slower
- for x, i := range buffer[buffc:buffi] {
- buffer[x] = i
- }
+ buffer = buffer[buffc:]
+ /*
+ for x, i := range buffer[buffc:buffi] {
+ buffer[x] = i
+ }
+ */
buffi -= buffc
// epsilonOffset -= buffo
@@ -597,7 +598,6 @@
if !textEnd {
w.TextEnd(buffc)
-
if DEBUG {
log.Println("Text end")
}