You are here

function _DiffEngine::_lcs_pos in Diff 5

Same name and namespace in other branches
  1. 5.2 DiffEngine.php \_DiffEngine::_lcs_pos()
  2. 6.2 DiffEngine.php \_DiffEngine::_lcs_pos()
  3. 6 DiffEngine.php \_DiffEngine::_lcs_pos()
  4. 7.3 DiffEngine.php \_DiffEngine::_lcs_pos()
  5. 7.2 DiffEngine.php \_DiffEngine::_lcs_pos()
1 call to _DiffEngine::_lcs_pos()
_DiffEngine::_diag in ./DiffEngine.php

File

./DiffEngine.php, line 329

Class

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

Code

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;
    }
  }
  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;
}