Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: Source/wtf/text/StringImpl.h

Issue 23464095: WTF::notFound looks too much like a local variable. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/wtf/Vector.h ('k') | Source/wtf/text/StringImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
4 * Copyright (C) 2009 Google Inc. All rights reserved. 4 * Copyright (C) 2009 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 WTF_EXPORT bool equalIgnoringNullity(StringImpl*, StringImpl*); 500 WTF_EXPORT bool equalIgnoringNullity(StringImpl*, StringImpl*);
501 501
502 template<typename CharacterType> 502 template<typename CharacterType>
503 inline size_t find(const CharacterType* characters, unsigned length, CharacterTy pe matchCharacter, unsigned index = 0) 503 inline size_t find(const CharacterType* characters, unsigned length, CharacterTy pe matchCharacter, unsigned index = 0)
504 { 504 {
505 while (index < length) { 505 while (index < length) {
506 if (characters[index] == matchCharacter) 506 if (characters[index] == matchCharacter)
507 return index; 507 return index;
508 ++index; 508 ++index;
509 } 509 }
510 return notFound; 510 return kNotFound;
511 } 511 }
512 512
513 ALWAYS_INLINE size_t find(const UChar* characters, unsigned length, LChar matchC haracter, unsigned index = 0) 513 ALWAYS_INLINE size_t find(const UChar* characters, unsigned length, LChar matchC haracter, unsigned index = 0)
514 { 514 {
515 return find(characters, length, static_cast<UChar>(matchCharacter), index); 515 return find(characters, length, static_cast<UChar>(matchCharacter), index);
516 } 516 }
517 517
518 inline size_t find(const LChar* characters, unsigned length, UChar matchCharacte r, unsigned index = 0) 518 inline size_t find(const LChar* characters, unsigned length, UChar matchCharacte r, unsigned index = 0)
519 { 519 {
520 if (matchCharacter & ~0xFF) 520 if (matchCharacter & ~0xFF)
521 return notFound; 521 return kNotFound;
522 return find(characters, length, static_cast<LChar>(matchCharacter), index); 522 return find(characters, length, static_cast<LChar>(matchCharacter), index);
523 } 523 }
524 524
525 inline size_t find(const LChar* characters, unsigned length, CharacterMatchFunct ionPtr matchFunction, unsigned index = 0) 525 inline size_t find(const LChar* characters, unsigned length, CharacterMatchFunct ionPtr matchFunction, unsigned index = 0)
526 { 526 {
527 while (index < length) { 527 while (index < length) {
528 if (matchFunction(characters[index])) 528 if (matchFunction(characters[index]))
529 return index; 529 return index;
530 ++index; 530 ++index;
531 } 531 }
532 return notFound; 532 return kNotFound;
533 } 533 }
534 534
535 inline size_t find(const UChar* characters, unsigned length, CharacterMatchFunct ionPtr matchFunction, unsigned index = 0) 535 inline size_t find(const UChar* characters, unsigned length, CharacterMatchFunct ionPtr matchFunction, unsigned index = 0)
536 { 536 {
537 while (index < length) { 537 while (index < length) {
538 if (matchFunction(characters[index])) 538 if (matchFunction(characters[index]))
539 return index; 539 return index;
540 ++index; 540 ++index;
541 } 541 }
542 return notFound; 542 return kNotFound;
543 } 543 }
544 544
545 template<typename CharacterType> 545 template<typename CharacterType>
546 inline size_t findNextLineStart(const CharacterType* characters, unsigned length , unsigned index = 0) 546 inline size_t findNextLineStart(const CharacterType* characters, unsigned length , unsigned index = 0)
547 { 547 {
548 while (index < length) { 548 while (index < length) {
549 CharacterType c = characters[index++]; 549 CharacterType c = characters[index++];
550 if ((c != '\n') && (c != '\r')) 550 if ((c != '\n') && (c != '\r'))
551 continue; 551 continue;
552 552
(...skipping 10 matching lines...) Expand all
563 if (c2 != '\n') 563 if (c2 != '\n')
564 return index; // Case 2: just \r. 564 return index; // Case 2: just \r.
565 565
566 // Case 1: \r\n. 566 // Case 1: \r\n.
567 // But, there's only a start of a new line if there are more 567 // But, there's only a start of a new line if there are more
568 // characters beyond the \r\n. 568 // characters beyond the \r\n.
569 if (++index < length) 569 if (++index < length)
570 return index; 570 return index;
571 } 571 }
572 } 572 }
573 return notFound; 573 return kNotFound;
574 } 574 }
575 575
576 template<typename CharacterType> 576 template<typename CharacterType>
577 inline size_t reverseFindLineTerminator(const CharacterType* characters, unsigne d length, unsigned index = UINT_MAX) 577 inline size_t reverseFindLineTerminator(const CharacterType* characters, unsigne d length, unsigned index = UINT_MAX)
578 { 578 {
579 if (!length) 579 if (!length)
580 return notFound; 580 return kNotFound;
581 if (index >= length) 581 if (index >= length)
582 index = length - 1; 582 index = length - 1;
583 CharacterType c = characters[index]; 583 CharacterType c = characters[index];
584 while ((c != '\n') && (c != '\r')) { 584 while ((c != '\n') && (c != '\r')) {
585 if (!index--) 585 if (!index--)
586 return notFound; 586 return kNotFound;
587 c = characters[index]; 587 c = characters[index];
588 } 588 }
589 return index; 589 return index;
590 } 590 }
591 591
592 template<typename CharacterType> 592 template<typename CharacterType>
593 inline size_t reverseFind(const CharacterType* characters, unsigned length, Char acterType matchCharacter, unsigned index = UINT_MAX) 593 inline size_t reverseFind(const CharacterType* characters, unsigned length, Char acterType matchCharacter, unsigned index = UINT_MAX)
594 { 594 {
595 if (!length) 595 if (!length)
596 return notFound; 596 return kNotFound;
597 if (index >= length) 597 if (index >= length)
598 index = length - 1; 598 index = length - 1;
599 while (characters[index] != matchCharacter) { 599 while (characters[index] != matchCharacter) {
600 if (!index--) 600 if (!index--)
601 return notFound; 601 return kNotFound;
602 } 602 }
603 return index; 603 return index;
604 } 604 }
605 605
606 ALWAYS_INLINE size_t reverseFind(const UChar* characters, unsigned length, LChar matchCharacter, unsigned index = UINT_MAX) 606 ALWAYS_INLINE size_t reverseFind(const UChar* characters, unsigned length, LChar matchCharacter, unsigned index = UINT_MAX)
607 { 607 {
608 return reverseFind(characters, length, static_cast<UChar>(matchCharacter), i ndex); 608 return reverseFind(characters, length, static_cast<UChar>(matchCharacter), i ndex);
609 } 609 }
610 610
611 inline size_t reverseFind(const LChar* characters, unsigned length, UChar matchC haracter, unsigned index = UINT_MAX) 611 inline size_t reverseFind(const LChar* characters, unsigned length, UChar matchC haracter, unsigned index = UINT_MAX)
612 { 612 {
613 if (matchCharacter & ~0xFF) 613 if (matchCharacter & ~0xFF)
614 return notFound; 614 return kNotFound;
615 return reverseFind(characters, length, static_cast<LChar>(matchCharacter), i ndex); 615 return reverseFind(characters, length, static_cast<LChar>(matchCharacter), i ndex);
616 } 616 }
617 617
618 inline size_t StringImpl::find(LChar character, unsigned start) 618 inline size_t StringImpl::find(LChar character, unsigned start)
619 { 619 {
620 if (is8Bit()) 620 if (is8Bit())
621 return WTF::find(characters8(), m_length, character, start); 621 return WTF::find(characters8(), m_length, character, start);
622 return WTF::find(characters16(), m_length, character, start); 622 return WTF::find(characters16(), m_length, character, start);
623 } 623 }
624 624
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 } 738 }
739 739
740 using WTF::StringImpl; 740 using WTF::StringImpl;
741 using WTF::equal; 741 using WTF::equal;
742 using WTF::equalNonNull; 742 using WTF::equalNonNull;
743 using WTF::TextCaseSensitivity; 743 using WTF::TextCaseSensitivity;
744 using WTF::TextCaseSensitive; 744 using WTF::TextCaseSensitive;
745 using WTF::TextCaseInsensitive; 745 using WTF::TextCaseInsensitive;
746 746
747 #endif 747 #endif
OLDNEW
« no previous file with comments | « Source/wtf/Vector.h ('k') | Source/wtf/text/StringImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698