diff options
author | Chris Lattner <sabre@nondot.org> | 2009-09-20 01:22:16 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-09-20 01:22:16 +0000 |
commit | 05a32c8ab118d9c92dc9b4ecaa7a6fed67241215 (patch) | |
tree | efb52de99a1604350ddcee6dddc64e94d8311478 /include/llvm | |
parent | fb2674d0de83cbf3b79c269bc694f612de148950 (diff) | |
download | external_llvm-05a32c8ab118d9c92dc9b4ecaa7a6fed67241215.zip external_llvm-05a32c8ab118d9c92dc9b4ecaa7a6fed67241215.tar.gz external_llvm-05a32c8ab118d9c92dc9b4ecaa7a6fed67241215.tar.bz2 |
move a couple non-trivial methods out of line, add new
find_first_of/find_first_of methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82347 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/ADT/StringRef.h | 62 |
1 files changed, 23 insertions, 39 deletions
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index f72a22d..510a51b 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -163,16 +163,8 @@ namespace llvm { /// /// \return - The index of the first occurence of \arg Str, or npos if not /// found. - size_t find(const StringRef &Str) const { - size_t N = Str.size(); - if (N > Length) - return npos; - for (size_t i = 0, e = Length - N + 1; i != e; ++i) - if (substr(i, N).equals(Str)) - return i; - return npos; - } - + size_t find(const StringRef &Str) const; + /// rfind - Search for the last character \arg C in the string. /// /// \return - The index of the last occurence of \arg C, or npos if not @@ -189,24 +181,29 @@ namespace llvm { size_t rfind(char C) const { return rfind(C, Length); } - - + /// rfind - Search for the last string \arg Str in the string. /// /// \return - The index of the last occurence of \arg Str, or npos if not /// found. - size_t rfind(const StringRef &Str) const { - size_t N = Str.size(); - if (N > Length) - return npos; - for (size_t i = Length - N + 1, e = 0; i != e;) { - --i; - if (substr(i, N).equals(Str)) - return i; - } - return npos; - } - + size_t rfind(const StringRef &Str) const; + + /// find_first_of - Find the first instance of the specified character or + /// return npos if not in string. Same as find. + size_type find_first_of(char C) const { return find(C); } + + /// find_first_of - Find the first character from the string 'Chars' in the + /// current string or return npos if not in string. + size_type find_first_of(StringRef Chars) const; + + /// find_first_not_of - Find the first character in the string that is not + /// in the string 'Chars' or return npos if all are in string. Same as find. + size_type find_first_not_of(StringRef Chars) const; + + /// @} + /// @name Helpful Algorithms + /// @{ + /// count - Return the number of occurrences of \arg C in the string. size_t count(char C) const { size_t Count = 0; @@ -215,23 +212,10 @@ namespace llvm { ++Count; return Count; } - + /// count - Return the number of non-overlapped occurrences of \arg Str in /// the string. - size_t count(const StringRef &Str) const { - size_t Count = 0; - size_t N = Str.size(); - if (N > Length) - return 0; - for (size_t i = 0, e = Length - N + 1; i != e; ++i) - if (substr(i, N).equals(Str)) - ++Count; - return Count; - } - - /// @} - /// @name Helpful Algorithms - /// @{ + size_t count(const StringRef &Str) const; /// getAsInteger - Parse the current string as an integer of the specified /// radix. If Radix is specified as zero, this does radix autosensing using |