Skip to content

Commit 0614f05

Browse files
committed
Use new SIMD function for non blank checking
1 parent 7b9b883 commit 0614f05

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

kittens/diff/patch.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -453,24 +453,16 @@ func (self *Patch) compute_centers(left_lines, right_lines []string) error {
453453
return nil
454454
}
455455

456+
// Use SIMD to efficiently find non-blank lines: a line is non-blank if it
457+
// contains at least one character that is not a space or tab.
458+
func is_non_blank(text string) bool {
459+
return simdstring.NotIndexByte2String(text, ' ', '\t') >= 0
460+
}
461+
456462
func (self *Patch) detect_moved_lines(left_lines, right_lines []string) {
457463
// Build maps from line text to lists of line numbers for removed and added lines.
458464
removed := make(map[string][]int) // text -> left line numbers
459465
added := make(map[string][]int) // text -> right line numbers
460-
// Use SIMD to efficiently find non-blank lines: a line is non-blank if it
461-
// contains at least one character that is not a space or tab.
462-
is_non_blank := func(text string) bool {
463-
for len(text) > 0 {
464-
idx := simdstring.IndexByte2String(text, ' ', '\t')
465-
if idx != 0 {
466-
// idx < 0: no space/tab found, remaining chars are non-blank;
467-
// idx > 0: non-blank chars exist before the first space/tab.
468-
return true
469-
}
470-
text = text[1:]
471-
}
472-
return false
473-
}
474466
for _, hunk := range self.all_hunks {
475467
for _, chunk := range hunk.chunks {
476468
if !chunk.is_context {

0 commit comments

Comments
 (0)