You are here

public function Diff::lcs in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Component/Diff/Diff.php \Drupal\Component\Diff\Diff::lcs()
  2. 10 core/lib/Drupal/Component/Diff/Diff.php \Drupal\Component\Diff\Diff::lcs()

Compute the length of the Longest Common Subsequence (LCS).

This is mostly for diagnostic purposed.

Return value

int The length of the LCS.

1 call to Diff::lcs()
Diff::check in core/lib/Drupal/Component/Diff/Diff.php
Check a Diff for validity.

File

core/lib/Drupal/Component/Diff/Diff.php, line 82

Class

Diff
Class representing a 'diff' between two sequences of strings. @todo document @subpackage DifferenceEngine

Namespace

Drupal\Component\Diff

Code

public function lcs() {
  $lcs = 0;
  foreach ($this->edits as $edit) {
    if ($edit->type == 'copy') {
      $lcs += sizeof($edit->orig);
    }
  }
  return $lcs;
}