From e5de1d13c493f80ff6cd21c51f77a4ed10088ea2 Mon Sep 17 00:00:00 2001 From: piegames Date: Tue, 15 Oct 2024 21:48:15 +0200 Subject: libexpr: Optimize complex indented strings The old behavior results in lots of concatenations happening for no good reason and is an artifact of the technical limitations of the old parser (combined with some lack of care for such details). Change-Id: I0d78d6220ca6aeaa10bc437e48e08bf7922e0bb3 --- src/libexpr/parser/parser-impl1.inc.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/libexpr/parser/parser-impl1.inc.cc') diff --git a/src/libexpr/parser/parser-impl1.inc.cc b/src/libexpr/parser/parser-impl1.inc.cc index c65fb3ddc..5836ab752 100644 --- a/src/libexpr/parser/parser-impl1.inc.cc +++ b/src/libexpr/parser/parser-impl1.inc.cc @@ -542,10 +542,10 @@ template<> struct BuildAST { } }; -template -struct BuildAST> { +template +struct BuildAST> { static void apply(const auto & in, IndStringState & s, State & ps) { - s.lines.back().parts.emplace_back(ps.at(in), StringToken{ in.string_view(), CanMerge }); + s.lines.back().parts.emplace_back(ps.at(in), in.string_view()); } }; @@ -558,10 +558,10 @@ template<> struct BuildAST { template<> struct BuildAST { static void apply(const auto & in, IndStringState & s, State & ps) { switch (*in.begin()) { - case 'n': s.lines.back().parts.emplace_back(ps.at(in), StringToken{"\n"}); break; - case 'r': s.lines.back().parts.emplace_back(ps.at(in), StringToken{"\r"}); break; - case 't': s.lines.back().parts.emplace_back(ps.at(in), StringToken{"\t"}); break; - default: s.lines.back().parts.emplace_back(ps.at(in), StringToken{in.string_view()}); break; + case 'n': s.lines.back().parts.emplace_back(ps.at(in), "\n"); break; + case 'r': s.lines.back().parts.emplace_back(ps.at(in), "\r"); break; + case 't': s.lines.back().parts.emplace_back(ps.at(in), "\t"); break; + default: s.lines.back().parts.emplace_back(ps.at(in), in.string_view()); break; } } }; -- cgit v1.2.3