diff options
author | piegames <git@piegames.de> | 2024-10-15 21:48:15 +0200 |
---|---|---|
committer | piegames <git@piegames.de> | 2024-10-18 19:37:23 +0200 |
commit | e5de1d13c493f80ff6cd21c51f77a4ed10088ea2 (patch) | |
tree | f96868291c386ef9b7ef8d3035bf58fa1821b78c /src/libexpr/parser/parser-impl1.inc.cc | |
parent | 878e18188215ad52784027c3489c7b4f6f0bcba3 (diff) |
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
Diffstat (limited to 'src/libexpr/parser/parser-impl1.inc.cc')
-rw-r--r-- | src/libexpr/parser/parser-impl1.inc.cc | 14 |
1 files changed, 7 insertions, 7 deletions
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<grammar::v1::ind_string::line_start> { } }; -template<bool CanMerge, typename... Content> -struct BuildAST<grammar::v1::ind_string::literal<CanMerge, Content...>> { +template<typename... Content> +struct BuildAST<grammar::v1::ind_string::literal<Content...>> { 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<grammar::v1::ind_string::interpolation> { template<> struct BuildAST<grammar::v1::ind_string::escape> { 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; } } }; |