diff options
| author | Maxime Coste <mawww@kakoune.org> | 2025-06-28 21:48:29 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2025-06-28 21:48:29 +1000 |
| commit | 8561c2377c287a86e4603f5880606b64c3432dc1 (patch) | |
| tree | bf07d6881130d6cddb275ad25fa1baecc09dc91f /src/string.cc | |
| parent | bc9dd1a962c82a0cd1a783995639c823f468e9a3 (diff) | |
Move some String constructors out of the header
Those do not really need to get inlined and pull std::max which
really wants <algorithm> which is an expensive header.
Diffstat (limited to 'src/string.cc')
| -rw-r--r-- | src/string.cc | 15 |
1 files changed, 15 insertions, 0 deletions
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; |
