View | Details | Return to bug 58358 | Differences between
and this patch

Collapse All | Expand All

(-)include/bits/stl_algo.h (-50 / +20 lines)
Lines 385-422 Link Here
385
	_DistanceType;
385
	_DistanceType;
386
386
387
      _DistanceType __tailSize = __last - __first;
387
      _DistanceType __tailSize = __last - __first;
388
      const _DistanceType __pattSize = __count;
388
      _DistanceType __remainder = __count;
389
389
390
      if (__tailSize < __pattSize)
390
      while (__remainder <= __tailSize) // the main loop...
391
        return __last;
392
393
      const _DistanceType __skipOffset = __pattSize - 1;
394
      _RandomAccessIter __lookAhead = __first + __skipOffset;
395
      __tailSize -= __pattSize;
396
397
      while (1) // the main loop...
398
	{
391
	{
399
	  // __lookAhead here is always pointing to the last element of next 
392
	  __first += __remainder;
393
	  __tailSize -= __remainder;
394
	  // __first here is always pointing to one past the last element of next
400
	  // possible match.
395
	  // possible match.
401
	  while (!(*__lookAhead == __val)) // the skip loop...
396
	  _RandomAccessIter __backTrack = __first; 
397
	  while (*--__backTrack == __val)
402
	    {
398
	    {
403
	      if (__tailSize < __pattSize)
404
		return __last;  // Failure
405
	      __lookAhead += __pattSize;
406
	      __tailSize -= __pattSize;
407
	    }
408
	  _DistanceType __remainder = __skipOffset;
409
	  for (_RandomAccessIter __backTrack = __lookAhead - 1; 
410
	       *__backTrack == __val; --__backTrack)
411
	    {
412
	      if (--__remainder == 0)
399
	      if (--__remainder == 0)
413
		return (__lookAhead - __skipOffset); // Success
400
	        return (__first - __count); // Success
414
	    }
401
	    }
415
	  if (__remainder > __tailSize)
402
	  __remainder = __count + 1 - (__first - __backTrack);
416
	    return __last; // Failure
417
	  __lookAhead += __remainder;
418
	  __tailSize -= __remainder;
419
	}
403
	}
404
      return __last; // Failure
420
    }
405
    }
421
406
422
  // search_n
407
  // search_n
Lines 478-515 Link Here
478
	_DistanceType;
463
	_DistanceType;
479
464
480
      _DistanceType __tailSize = __last - __first;
465
      _DistanceType __tailSize = __last - __first;
481
      const _DistanceType __pattSize = __count;
466
      _DistanceType __remainder = __count;
482
467
483
      if (__tailSize < __pattSize)
468
      while (__remainder <= __tailSize) // the main loop...
484
        return __last;
485
486
      const _DistanceType __skipOffset = __pattSize - 1;
487
      _RandomAccessIter __lookAhead = __first + __skipOffset;
488
      __tailSize -= __pattSize;
489
490
      while (1) // the main loop...
491
	{
469
	{
492
	  // __lookAhead here is always pointing to the last element of next 
470
	  __first += __remainder;
471
	  __tailSize -= __remainder;
472
	  // __first here is always pointing to one past the last element of next
493
	  // possible match.
473
	  // possible match.
494
	  while (!bool(__binary_pred(*__lookAhead, __val))) // the skip loop...
474
	  _RandomAccessIter __backTrack = __first; 
475
	  while (__binary_pred(*--__backTrack, __val))
495
	    {
476
	    {
496
	      if (__tailSize < __pattSize)
497
		return __last;  // Failure
498
	      __lookAhead += __pattSize;
499
	      __tailSize -= __pattSize;
500
	    }
501
	  _DistanceType __remainder = __skipOffset;
502
	  for (_RandomAccessIter __backTrack = __lookAhead - 1; 
503
	       __binary_pred(*__backTrack, __val); --__backTrack)
504
	    {
505
	      if (--__remainder == 0)
477
	      if (--__remainder == 0)
506
		return (__lookAhead - __skipOffset); // Success
478
	        return (__first - __count); // Success
507
	    }
479
	    }
508
	  if (__remainder > __tailSize)
480
	  __remainder = __count + 1 - (__first - __backTrack);
509
	    return __last; // Failure
510
	  __lookAhead += __remainder;
511
	  __tailSize -= __remainder;
512
	}
481
	}
482
      return __last; // Failure
513
    }
483
    }
514
484
515
  // find_end for forward iterators.
485
  // find_end for forward iterators.

Return to bug 58358