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
diff --git a/lib/Rewrite/InclusionRewriter.cpp b/lib/Rewrite/InclusionRewriter.cpp
index c6a4e24..8fb5a8b 100644
--- a/lib/Rewrite/InclusionRewriter.cpp
+++ b/lib/Rewrite/InclusionRewriter.cpp
@@ -174,16 +174,6 @@
   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 @@
     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')