From 8561c2377c287a86e4603f5880606b64c3432dc1 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 28 Jun 2025 21:48:29 +1000 Subject: Move some String constructors out of the header Those do not really need to get inlined and pull std::max which really wants which is an expensive header. --- src/string.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/string.cc') diff --git a/src/string.cc b/src/string.cc index 353a9f4e..551add2d 100644 --- a/src/string.cc +++ b/src/string.cc @@ -118,6 +118,21 @@ void String::Data::clear() set_empty(); } +String::String(Codepoint cp, CharCount count) +{ + reserve(utf8::codepoint_size(cp) * (int)count); + while (count-- > 0) + utf8::dump(std::back_inserter(*this), cp); +} + +String::String(Codepoint cp, ColumnCount count) +{ + int cp_count = (int)(count / max(codepoint_width(cp), 1_col)); + reserve(utf8::codepoint_size(cp) * cp_count); + while (cp_count-- > 0) + utf8::dump(std::back_inserter(*this), cp); +} + void String::resize(ByteCount size, char c) { const size_t target_size = (size_t)size; -- cgit v1.2.3