File tree Expand file tree Collapse file tree 2 files changed +17
-14
lines changed
Expand file tree Collapse file tree 2 files changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,21 @@ void String::Data::clear()
118118 set_empty ();
119119}
120120
121+ String::String (Codepoint cp, CharCount count)
122+ {
123+ reserve (utf8::codepoint_size (cp) * (int )count);
124+ while (count-- > 0 )
125+ utf8::dump (std::back_inserter (*this ), cp);
126+ }
127+
128+ String::String (Codepoint cp, ColumnCount count)
129+ {
130+ int cp_count = (int )(count / max (codepoint_width (cp), 1_col));
131+ reserve (utf8::codepoint_size (cp) * cp_count);
132+ while (cp_count-- > 0 )
133+ utf8::dump (std::back_inserter (*this ), cp);
134+ }
135+
121136void String::resize (ByteCount size, char c)
122137{
123138 const size_t target_size = (size_t )size;
Original file line number Diff line number Diff line change @@ -109,21 +109,9 @@ public:
109109 String () {}
110110 String (const char * content) : m_data(content, (size_t )strlen(content)) {}
111111 String (const char * content, ByteCount len) : m_data(content, (size_t )len) {}
112- explicit String (Codepoint cp, CharCount count = 1 )
113- {
114- reserve (utf8::codepoint_size (cp) * (int )count);
115- while (count-- > 0 )
116- utf8::dump (std::back_inserter (*this ), cp);
117- }
118- explicit String (Codepoint cp, ColumnCount count)
119- {
120- int cp_count = (int )(count / std::max (codepoint_width (cp), 1_col));
121- reserve (utf8::codepoint_size (cp) * cp_count);
122- while (cp_count-- > 0 )
123- utf8::dump (std::back_inserter (*this ), cp);
124- }
125112 String (const char * begin, const char * end) : m_data(begin, end-begin) {}
126-
113+ explicit String (Codepoint cp, CharCount count = 1 );
114+ explicit String (Codepoint cp, ColumnCount count);
127115 explicit String (StringView str);
128116
129117 struct NoCopy {};
You can’t perform that action at this time.
0 commit comments