comparison core/lib/Drupal/Component/Diff/Engine/DiffEngine.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
199 $line = $flip ? $this->yv[$x] : $this->xv[$x]; 199 $line = $flip ? $this->yv[$x] : $this->xv[$x];
200 if (empty($ymatches[$line])) { 200 if (empty($ymatches[$line])) {
201 continue; 201 continue;
202 } 202 }
203 $matches = $ymatches[$line]; 203 $matches = $ymatches[$line];
204 reset($matches); 204 $found_empty = FALSE;
205 while (list ($junk, $y) = each($matches)) { 205 foreach ($matches as $y) {
206 if (empty($this->in_seq[$y])) { 206 if (!$found_empty) {
207 $k = $this->_lcs_pos($y); 207 if (empty($this->in_seq[$y])) {
208 $this::USE_ASSERTS && assert($k > 0); 208 $k = $this->_lcs_pos($y);
209 $ymids[$k] = $ymids[$k - 1]; 209 $this::USE_ASSERTS && assert($k > 0);
210 break; 210 $ymids[$k] = $ymids[$k - 1];
211 } 211 $found_empty = TRUE;
212 } 212 }
213 while (list ($junk, $y) = each($matches)) { 213 }
214 if ($y > $this->seq[$k - 1]) { 214 else {
215 $this::USE_ASSERTS && assert($y < $this->seq[$k]); 215 if ($y > $this->seq[$k - 1]) {
216 // Optimization: this is a common case: 216 $this::USE_ASSERTS && assert($y < $this->seq[$k]);
217 // next match is just replacing previous match. 217 // Optimization: this is a common case:
218 $this->in_seq[$this->seq[$k]] = FALSE; 218 // next match is just replacing previous match.
219 $this->seq[$k] = $y; 219 $this->in_seq[$this->seq[$k]] = FALSE;
220 $this->in_seq[$y] = 1; 220 $this->seq[$k] = $y;
221 } 221 $this->in_seq[$y] = 1;
222 elseif (empty($this->in_seq[$y])) { 222 }
223 $k = $this->_lcs_pos($y); 223 elseif (empty($this->in_seq[$y])) {
224 $this::USE_ASSERTS && assert($k > 0); 224 $k = $this->_lcs_pos($y);
225 $ymids[$k] = $ymids[$k - 1]; 225 $this::USE_ASSERTS && assert($k > 0);
226 $ymids[$k] = $ymids[$k - 1];
227 }
226 } 228 }
227 } 229 }
228 } 230 }
229 } 231 }
230 232
341 */ 343 */
342 protected function _shift_boundaries($lines, &$changed, $other_changed) { 344 protected function _shift_boundaries($lines, &$changed, $other_changed) {
343 $i = 0; 345 $i = 0;
344 $j = 0; 346 $j = 0;
345 347
346 $this::USE_ASSERTS && assert('sizeof($lines) == sizeof($changed)'); 348 $this::USE_ASSERTS && assert(sizeof($lines) == sizeof($changed));
347 $len = sizeof($lines); 349 $len = sizeof($lines);
348 $other_len = sizeof($other_changed); 350 $other_len = sizeof($other_changed);
349 351
350 while (1) { 352 while (1) {
351 /* 353 /*
361 */ 363 */
362 while ($j < $other_len && $other_changed[$j]) { 364 while ($j < $other_len && $other_changed[$j]) {
363 $j++; 365 $j++;
364 } 366 }
365 while ($i < $len && !$changed[$i]) { 367 while ($i < $len && !$changed[$i]) {
366 $this::USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); 368 $this::USE_ASSERTS && assert($j < $other_len && ! $other_changed[$j]);
367 $i++; 369 $i++;
368 $j++; 370 $j++;
369 while ($j < $other_len && $other_changed[$j]) { 371 while ($j < $other_len && $other_changed[$j]) {
370 $j++; 372 $j++;
371 } 373 }
397 $changed[--$start] = 1; 399 $changed[--$start] = 1;
398 $changed[--$i] = FALSE; 400 $changed[--$i] = FALSE;
399 while ($start > 0 && $changed[$start - 1]) { 401 while ($start > 0 && $changed[$start - 1]) {
400 $start--; 402 $start--;
401 } 403 }
402 $this::USE_ASSERTS && assert('$j > 0'); 404 $this::USE_ASSERTS && assert($j > 0);
403 while ($other_changed[--$j]) { 405 while ($other_changed[--$j]) {
404 continue; 406 continue;
405 } 407 }
406 $this::USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); 408 $this::USE_ASSERTS && assert($j >= 0 && !$other_changed[$j]);
407 } 409 }
408 410
409 /* 411 /*
410 * Set CORRESPONDING to the end of the changed run, at the last 412 * Set CORRESPONDING to the end of the changed run, at the last
411 * point where it corresponds to a changed run in the other file. 413 * point where it corresponds to a changed run in the other file.
424 $changed[$start++] = FALSE; 426 $changed[$start++] = FALSE;
425 $changed[$i++] = 1; 427 $changed[$i++] = 1;
426 while ($i < $len && $changed[$i]) { 428 while ($i < $len && $changed[$i]) {
427 $i++; 429 $i++;
428 } 430 }
429 $this::USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); 431 $this::USE_ASSERTS && assert($j < $other_len && ! $other_changed[$j]);
430 $j++; 432 $j++;
431 if ($j < $other_len && $other_changed[$j]) { 433 if ($j < $other_len && $other_changed[$j]) {
432 $corresponding = $i; 434 $corresponding = $i;
433 while ($j < $other_len && $other_changed[$j]) { 435 while ($j < $other_len && $other_changed[$j]) {
434 $j++; 436 $j++;
442 * back to a corresponding run in the other file. 444 * back to a corresponding run in the other file.
443 */ 445 */
444 while ($corresponding < $i) { 446 while ($corresponding < $i) {
445 $changed[--$start] = 1; 447 $changed[--$start] = 1;
446 $changed[--$i] = 0; 448 $changed[--$i] = 0;
447 $this::USE_ASSERTS && assert('$j > 0'); 449 $this::USE_ASSERTS && assert($j > 0);
448 while ($other_changed[--$j]) { 450 while ($other_changed[--$j]) {
449 continue; 451 continue;
450 } 452 }
451 $this::USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); 453 $this::USE_ASSERTS && assert($j >= 0 && !$other_changed[$j]);
452 } 454 }
453 } 455 }
454 } 456 }
455 457
456 } 458 }