From 1ebf937a6ca2d227c0bec9360e23866ada307d66 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 9 Oct 2020 17:46:55 -0400 Subject: [PATCH] Internals: Favor std method. No functional change intended. --- src/V3PreProc.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index ec9047731..49adf7d48 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -26,6 +26,7 @@ #include "V3PreShell.h" #include "V3String.h" +#include #include #include #include @@ -540,10 +541,7 @@ void V3PreProcImp::unputString(const string& strg) { } void V3PreProcImp::unputDefrefString(const string& strg) { - int multiline = 0; - for (size_t i = 0; i < strg.length(); i++) { - if (strg[i] == '\n') multiline++; - } + int multiline = std::count(strg.begin(), strg.end(), '\n'); unputString(strg); // A define that inserts multiple newlines are really attributed to one source line, // so temporarily don't increment lineno. @@ -1320,7 +1318,7 @@ int V3PreProcImp::getStateToken() { // multiline "..." without \ escapes. // The spec is silent about this either way; simulators vary string::size_type pos; - while ((pos = out.find('\n')) != string::npos) out.replace(pos, 1, " "); + std::replace(out.begin(), out.end(), '\n', ' '); unputString(string("\"") + out + "\""); statePop(); goto next_tok;