Changeset 65571 in webkit for trunk/JavaScriptCore/wtf/text/StringImpl.cpp
- Timestamp:
- Aug 17, 2010, 4:05:50 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/text/StringImpl.cpp
r65493 r65571 543 543 } 544 544 545 for (unsigned i = 0; i < delta; ++i) { 546 if (searchHash == matchHash && equal(searchCharacters + i, matchString, matchLength)) 547 return index + i; 545 unsigned i = 0; 546 // keep looping until we match 547 while (searchHash != matchHash || !equal(searchCharacters + i, matchString, matchLength)) { 548 if (i == delta) 549 return notFound; 548 550 searchHash += searchCharacters[i + matchLength]; 549 551 searchHash -= searchCharacters[i]; 550 } 551 if (searchHash == matchHash && equal(searchCharacters + delta, matchString, matchLength)) 552 return index + delta; 553 return notFound; 552 ++i; 553 } 554 return index + i; 554 555 } 555 556 … … 574 575 const UChar* searchCharacters = characters() + index; 575 576 576 for (unsigned i = 0; i <= delta; ++i) { 577 if (equalIgnoringCase(searchCharacters + i, matchString, matchLength)) 578 return index + i; 579 } 580 return notFound; 577 unsigned i = 0; 578 // keep looping until we match 579 while (!equalIgnoringCase(searchCharacters + i, matchString, matchLength)) { 580 if (i == delta) 581 return notFound; 582 ++i; 583 } 584 return index + i; 581 585 } 582 586 … … 615 619 } 616 620 617 for (unsigned i = 0; i <= delta; ++i) { 618 if (searchHash == matchHash && memcmp(searchCharacters + i, matchCharacters, matchLength * sizeof(UChar)) == 0) 619 return index + i; 621 unsigned i = 0; 622 // keep looping until we match 623 while (searchHash != matchHash || memcmp(searchCharacters + i, matchCharacters, matchLength * sizeof(UChar))) { 624 if (i == delta) 625 return notFound; 620 626 searchHash += searchCharacters[i + matchLength]; 621 627 searchHash -= searchCharacters[i]; 622 } 623 return notFound; 628 ++i; 629 } 630 return index + i; 624 631 } 625 632 … … 645 652 const UChar* matchCharacters = matchString->characters(); 646 653 647 for (unsigned i = 0; i <= delta; ++i) { 648 if (equalIgnoringCase(searchCharacters + i, matchCharacters, matchLength)) 649 return index + i; 650 } 651 return notFound; 654 unsigned i = 0; 655 // keep looping until we match 656 while (!equalIgnoringCase(searchCharacters + i, matchCharacters, matchLength)) { 657 if (i == delta) 658 return notFound; 659 ++i; 660 } 661 return index + i; 652 662 } 653 663 … … 688 698 } 689 699 700 // keep looping until we match 690 701 while (searchHash != matchHash || memcmp(searchCharacters + delta, matchCharacters, matchLength * sizeof(UChar))) { 691 if (!delta --)702 if (!delta) 692 703 return notFound; 704 delta--; 693 705 searchHash -= searchCharacters[delta + matchLength]; 694 706 searchHash += searchCharacters[delta]; … … 715 727 const UChar *matchCharacters = matchString->characters(); 716 728 729 // keep looping until we match 717 730 while (!equalIgnoringCase(searchCharacters + delta, matchCharacters, matchLength)) { 718 if (!delta --)731 if (!delta) 719 732 return notFound; 733 delta--; 720 734 } 721 735 return delta;
Note:
See TracChangeset
for help on using the changeset viewer.