diff options
author | Takuto Ikuta <tikuta@google.com> | 2017-04-26 07:10:27 (GMT) |
---|---|---|
committer | Takuto Ikuta <tikuta@google.com> | 2017-04-26 08:27:54 (GMT) |
commit | 08a3220bc2fe12e7f05967b317d221e0bc620be9 (patch) | |
tree | 3bf56ac3ae430b6e5c66e3bb93b74eec2f1db4f0 /src/string_piece.h | |
parent | 586bb6daef38b3657ba917eb3d7f07ba80c72cd7 (diff) | |
download | Ninja-08a3220bc2fe12e7f05967b317d221e0bc620be9.zip Ninja-08a3220bc2fe12e7f05967b317d221e0bc620be9.tar.gz Ninja-08a3220bc2fe12e7f05967b317d221e0bc620be9.tar.bz2 |
Add string_piece_util
Following functions are implemented for further performance
optimization.
* JoinStringPiece
* SplitStringPiece
* EqualsCaseInsensitiveASCII
* ToLowerASCII
To improve performance of CLParser, I will introduce above functions
into include_normalize-win32.cc.
Diffstat (limited to 'src/string_piece.h')
-rw-r--r-- | src/string_piece.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/string_piece.h b/src/string_piece.h index b1bf105..353b24e 100644 --- a/src/string_piece.h +++ b/src/string_piece.h @@ -25,6 +25,8 @@ using namespace std; /// externally. It is useful for reducing the number of std::strings /// we need to allocate. struct StringPiece { + typedef const char* const_iterator; + StringPiece() : str_(NULL), len_(0) {} /// The constructors intentionally allow for implicit conversions. @@ -46,6 +48,14 @@ struct StringPiece { return len_ ? string(str_, len_) : string(); } + const_iterator begin() const { + return str_; + } + + const_iterator end() const { + return str_ + len_; + } + const char* str_; size_t len_; }; |