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 | 3159819ed71a2e814175a593147f7637a423ba56 (patch) | |
tree | c2972c1550f49fc0af688ca4e8471044a48499dd | |
parent | 681ab8998793899076bae9cd6383a5d78b8ee1ac (diff) |
Replace a char counting helper function with std::count.
No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158272 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Rewrite/InclusionRewriter.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/lib/Rewrite/InclusionRewriter.cpp b/lib/Rewrite/InclusionRewriter.cpp index c6a4e24c7a..8fb5a8b32f 100644 --- a/lib/Rewrite/InclusionRewriter.cpp +++ b/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') |