MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / bisect_split

Method bisect_split

src/licensedcode/dmp.py:360–384  ·  view source on GitHub ↗

Given the location of the 'middle snake', split the diff in two parts and recurse. Args: text1: Old string to be diffed. text2: New string to be diffed. x: Index of split point in text1. y: Index of split point in text2. dea

(self, text1, text2, x, y, deadline)

Source from the content-addressed store, hash-verified

358 return [(DIFF_DELETE, text1), (DIFF_INSERT, text2)]
359
360 def bisect_split(self, text1, text2, x, y, deadline):
361 """
362 Given the location of the 'middle snake', split the diff in two parts
363 and recurse.
364
365 Args:
366 text1: Old string to be diffed.
367 text2: New string to be diffed.
368 x: Index of split point in text1.
369 y: Index of split point in text2.
370 deadline: Time at which to bail if not yet complete.
371
372 Returns:
373 Array of diff tuples.
374 """
375 text1a = text1[:x]
376 text2a = text2[:y]
377 text1b = text1[x:]
378 text2b = text2[y:]
379
380 # Compute both diffs serially.
381 diffs = self.difference(text1a, text2a, deadline)
382 diffsb = self.difference(text1b, text2b, deadline)
383
384 return diffs + diffsb
385
386
387def half_match(text1, text2, len_text1, len_text2):

Callers 1

bisectMethod · 0.95

Calls 1

differenceMethod · 0.95

Tested by

no test coverage detected