From aadd893e9d4a44cc57eaa1a57eefb20f7fd39da8 Mon Sep 17 00:00:00 2001 From: Alexander Guryanov Date: Fri, 27 Oct 2023 09:52:24 +0300 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Alon Zakai --- src/support/string.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/support/string.h b/src/support/string.h index ed579fd220d..0259f3bcd73 100644 --- a/src/support/string.h +++ b/src/support/string.h @@ -32,7 +32,11 @@ namespace wasm::String { // Creates a vector of the split parts of a string, by a delimiter. class Split : public std::vector { private: + // If we split on newlines then we do not need to handle bracketing at all. Otherwise, + // splitting on say "," does require us to understanding the scoping of brackets, e.g., + // "foo(x, y),bar" should be split as "foo(x, y)", "bar". bool needToHandleBracketingOperations = true; + void split(const std::string& input, const std::string& delim) { size_t lastEnd = 0; while (lastEnd < input.size()) { @@ -47,7 +51,10 @@ class Split : public std::vector { } friend String::Split handleBracketingOperators(String::Split split); + public: + // This can be used when we want to split on newlines if there are any, and if there are not, + // then using the given delimiter. struct NewLineOr { const std::string delim; explicit NewLineOr(const std::string& delim) : delim(delim) {}