diff options
author | Nico Weber <nicolasweber@gmx.de> | 2017-05-11 15:59:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-11 15:59:55 (GMT) |
commit | f1551b37cc57ba7172e17bf8e5b57a996a06365d (patch) | |
tree | 0c398e386cf3cc6d78e410976935bc5480051de3 /src/string_piece.h | |
parent | 586bb6daef38b3657ba917eb3d7f07ba80c72cd7 (diff) | |
parent | f0bb90e4bc49167fac5213269a34f628c349e50c (diff) | |
download | Ninja-f1551b37cc57ba7172e17bf8e5b57a996a06365d.zip Ninja-f1551b37cc57ba7172e17bf8e5b57a996a06365d.tar.gz Ninja-f1551b37cc57ba7172e17bf8e5b57a996a06365d.tar.bz2 |
Merge pull request #1271 from atetubou/faster_clparser
Faster clparser
Diffstat (limited to 'src/string_piece.h')
-rw-r--r-- | src/string_piece.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/string_piece.h b/src/string_piece.h index b1bf105..031bda4 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,22 @@ struct StringPiece { return len_ ? string(str_, len_) : string(); } + const_iterator begin() const { + return str_; + } + + const_iterator end() const { + return str_ + len_; + } + + char operator[](size_t pos) const { + return str_[pos]; + } + + size_t size() const { + return len_; + } + const char* str_; size_t len_; }; |