Skip to content

Commit

Permalink
Remove redundancies
Browse files Browse the repository at this point in the history
  • Loading branch information
clipperhouse committed Aug 30, 2024
1 parent 733dd06 commit eee045c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
6 changes: 3 additions & 3 deletions phrases/splitfunc.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func SplitFunc(data []byte, atEOF bool) (advance int, token []byte, err error) {
}

// https://unicode.org/reports/tr29/#WB7
if current.is(_AHLetter) && lastExIgnore.is(_MidLetter|_MidNumLetQ|_Ignore) && lastLastExIgnore.is(_AHLetter) {
if current.is(_AHLetter) && lastExIgnore.is(_MidLetter|_MidNumLetQ) && lastLastExIgnore.is(_AHLetter) {
pos += w
continue
}
Expand All @@ -149,7 +149,7 @@ func SplitFunc(data []byte, atEOF bool) (advance int, token []byte, err error) {
}

// https://unicode.org/reports/tr29/#WB7b
if current.is(_DoubleQuote) && lastExIgnore.is(_HebrewLetter|_Ignore) {
if current.is(_DoubleQuote) && lastExIgnore.is(_HebrewLetter) {
found, more := subsequent(_HebrewLetter, data[pos+w:], atEOF)

if more {
Expand All @@ -164,7 +164,7 @@ func SplitFunc(data []byte, atEOF bool) (advance int, token []byte, err error) {
}

// https://unicode.org/reports/tr29/#WB7c
if current.is(_HebrewLetter) && lastExIgnore.is(_DoubleQuote|_Ignore) && lastLastExIgnore.is(_HebrewLetter) {
if current.is(_HebrewLetter) && lastExIgnore.is(_DoubleQuote) && lastLastExIgnore.is(_HebrewLetter) {
pos += w
continue
}
Expand Down
18 changes: 5 additions & 13 deletions sentences/splitfunc.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,14 @@ main:

// https://unicode.org/reports/tr29/#SB6
if current.is(_Numeric) && lastExIgnore.is(_ATerm) {
if previous(_ATerm, data[:pos]) {
pos += w
continue
}
pos += w
continue
}

// Optimization: determine if SB7 can possibly apply
maybeSB7 := current.is(_Upper) && last.is(_ATerm|_Ignore) && lastLastExIgnore.is(_Upper|_Lower)

// https://unicode.org/reports/tr29/#SB7
if maybeSB7 {
pi := previousIndex(_ATerm, data[:pos])
if pi >= 0 && previous(_Upper|_Lower, data[:pi]) {
pos += w
continue
}
if current.is(_Upper) && lastExIgnore.is(_ATerm) && lastLastExIgnore.is(_Upper|_Lower) {
pos += w
continue
}

// Optimization: determine if SB8 can possibly apply
Expand Down
6 changes: 3 additions & 3 deletions words/splitfunc.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func SplitFunc(data []byte, atEOF bool) (advance int, token []byte, err error) {
}

// https://unicode.org/reports/tr29/#WB7
if current.is(_AHLetter) && lastExIgnore.is(_MidLetter|_MidNumLetQ|_Ignore) && lastLastExIgnore.is(_AHLetter) {
if current.is(_AHLetter) && lastExIgnore.is(_MidLetter|_MidNumLetQ) && lastLastExIgnore.is(_AHLetter) {
pos += w
continue
}
Expand All @@ -149,7 +149,7 @@ func SplitFunc(data []byte, atEOF bool) (advance int, token []byte, err error) {
}

// https://unicode.org/reports/tr29/#WB7b
if current.is(_DoubleQuote) && lastExIgnore.is(_HebrewLetter|_Ignore) {
if current.is(_DoubleQuote) && lastExIgnore.is(_HebrewLetter) {
found, more := subsequent(_HebrewLetter, data[pos+w:], atEOF)

if more {
Expand All @@ -164,7 +164,7 @@ func SplitFunc(data []byte, atEOF bool) (advance int, token []byte, err error) {
}

// https://unicode.org/reports/tr29/#WB7c
if current.is(_HebrewLetter) && lastExIgnore.is(_DoubleQuote|_Ignore) && lastLastExIgnore.is(_HebrewLetter) {
if current.is(_HebrewLetter) && lastExIgnore.is(_DoubleQuote) && lastLastExIgnore.is(_HebrewLetter) {
pos += w
continue
}
Expand Down

0 comments on commit eee045c

Please sign in to comment.