1 diff.inc private DiffEngine::lcsPos($ypos)

Parameters

$ypos:

Return value

int:

File

core/includes/diff.inc, line 429
A PHP diff engine for phpwiki. (Taken from phpwiki-1.3.3)

Class

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

Code

private function lcsPos($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;
    }
  }

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

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

  return $end;
}