protected function DiffEngine::_lcs_pos

protected DiffEngine::_lcs_pos($ypos)

File

core/lib/Drupal/Component/Diff/Engine/DiffEngine.php, line 243

Class

DiffEngine
Class used internally by Diff to actually compute the diffs.

Namespace

Drupal\Component\Diff\Engine

Code

protected function _lcs_pos($ypos) {

  $end = $this->lcs;
  if ($end == 0 || $ypos > $this->seq[$end]) {
    $this->seq[++$this->lcs] = $ypos;
    $this->in_seq[$ypos] = 1;
    return $this->lcs;
  }

  $beg = 1;
  while ($beg < $end) {
    $mid = (int) (($beg + $end) / 2);
    if ($ypos > $this->seq[$mid]) {
      $beg = $mid + 1;
    }
    else {
      $end = $mid;
    }
  }

  $this::USE_ASSERTS && assert($ypos != $this->seq[$end]);

  $this->in_seq[$this->seq[$end]] = FALSE;
  $this->seq[$end] = $ypos;
  $this->in_seq[$ypos] = 1;
  return $end;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Diff!Engine!DiffEngine.php/function/DiffEngine::_lcs_pos/8.1.x