Skip to content

Commit 9cc2d29

Browse files
author
Julien "_FrnchFrgg_" RIVAUD
committed
Call b2j.isBJunk directly and remove wrapper
1 parent e9a9573 commit 9cc2d29

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

difflib/bytes/bytes.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,6 @@ func (m *SequenceMatcher) chainB() {
253253
m.b2j = b2j
254254
}
255255

256-
func (m *SequenceMatcher) isBJunk(s []byte) bool {
257-
return m.b2j.isBJunk(s)
258-
}
259-
260256
// Find longest matching block in a[alo:ahi] and b[blo:bhi].
261257
//
262258
// If IsJunk is not defined:
@@ -324,12 +320,12 @@ func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Match {
324320
// "popular" non-junk elements aren't in b2j, which greatly speeds
325321
// the inner loop above, but also means "the best" match so far
326322
// doesn't contain any junk *or* popular non-junk elements.
327-
for besti > alo && bestj > blo && !m.isBJunk(m.b[bestj-1]) &&
323+
for besti > alo && bestj > blo && !m.b2j.isBJunk(m.b[bestj-1]) &&
328324
bytes.Equal(m.a[besti-1], m.b[bestj-1]) {
329325
besti, bestj, bestsize = besti-1, bestj-1, bestsize+1
330326
}
331327
for besti+bestsize < ahi && bestj+bestsize < bhi &&
332-
!m.isBJunk(m.b[bestj+bestsize]) &&
328+
!m.b2j.isBJunk(m.b[bestj+bestsize]) &&
333329
bytes.Equal(m.a[besti+bestsize], m.b[bestj+bestsize]) {
334330
bestsize += 1
335331
}
@@ -341,12 +337,12 @@ func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Match {
341337
// figuring out what to do with it. In the case of an empty
342338
// interesting match, this is clearly the right thing to do,
343339
// because no other kind of match is possible in the regions.
344-
for besti > alo && bestj > blo && m.isBJunk(m.b[bestj-1]) &&
340+
for besti > alo && bestj > blo && m.b2j.isBJunk(m.b[bestj-1]) &&
345341
bytes.Equal(m.a[besti-1], m.b[bestj-1]) {
346342
besti, bestj, bestsize = besti-1, bestj-1, bestsize+1
347343
}
348344
for besti+bestsize < ahi && bestj+bestsize < bhi &&
349-
m.isBJunk(m.b[bestj+bestsize]) &&
345+
m.b2j.isBJunk(m.b[bestj+bestsize]) &&
350346
bytes.Equal(m.a[besti+bestsize], m.b[bestj+bestsize]) {
351347
bestsize += 1
352348
}

0 commit comments

Comments
 (0)