diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-06-09 13:18:14 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-06-09 13:18:14 +0000 |
| commit | 7132638995ac396d69b4ffe8fe2baf8429c96d1c (patch) | |
| tree | b10d4bfe24b2d5e983c1f8278c950dd14df07d4b /clang | |
| parent | a74cf08e6882958b883911bff343c4b29cfddb07 (diff) | |
| download | bcm5719-llvm-7132638995ac396d69b4ffe8fe2baf8429c96d1c.tar.gz bcm5719-llvm-7132638995ac396d69b4ffe8fe2baf8429c96d1c.zip | |
Replace a char counting helper function with std::count.
No functionality change.
llvm-svn: 158272
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Rewrite/InclusionRewriter.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/clang/lib/Rewrite/InclusionRewriter.cpp b/clang/lib/Rewrite/InclusionRewriter.cpp index c6a4e24c7af..8fb5a8b32f8 100644 --- a/clang/lib/Rewrite/InclusionRewriter.cpp +++ b/clang/lib/Rewrite/InclusionRewriter.cpp @@ -174,16 +174,6 @@ InclusionRewriter::FindFileChangeLocation(SourceLocation Loc) const { return NULL; } -/// Count the raw \\n characters in the \p Len characters from \p Pos. -inline unsigned CountNewLines(const char *Pos, int Len) { - const char *End = Pos + Len; - unsigned Lines = 0; - --Pos; - while ((Pos = static_cast<const char*>(memchr(Pos + 1, '\n', End - Pos - 1)))) - ++Lines; - return Lines; -} - /// Detect the likely line ending style of \p FromFile by examining the first /// newline found within it. static StringRef DetectEOL(const MemoryBuffer &FromFile) { @@ -209,8 +199,8 @@ void InclusionRewriter::OutputContentUpTo(const MemoryBuffer &FromFile, return; OS.write(FromFile.getBufferStart() + WriteFrom, WriteTo - WriteFrom); // count lines manually, it's faster than getPresumedLoc() - Line += CountNewLines(FromFile.getBufferStart() + WriteFrom, - WriteTo - WriteFrom); + Line += std::count(FromFile.getBufferStart() + WriteFrom, + FromFile.getBufferStart() + WriteTo, '\n'); if (EnsureNewline) { char LastChar = FromFile.getBufferStart()[WriteTo - 1]; if (LastChar != '\n' && LastChar != '\r') |

