@@ -135,7 +135,7 @@ class FixedSizeStringBuffer {
135135 // / @brief access element using rb[1] notation
136136 inline std::string operator [](size_t pos) const { return at (pos); }
137137 // / @brief access element using rb.at(1) notation
138- inline std::string at (size_t pos) const ; // see below
138+ inline std::string at (size_t pos) const ; // implementation below
139139
140140 // ***********************************************************************
141141 // / @name Debug
@@ -178,7 +178,7 @@ class FixedSizeStringBuffer {
178178 // @}
179179
180180 private:
181- // used for pretty print of buffer
181+ // marker for char position used for pretty print of buffer
182182 struct SlotState {
183183 std::vector<bool > bopen;
184184 std::vector<bool > bword;
@@ -227,7 +227,8 @@ void FixedSizeStringBuffer<SPACE>::push(std::string_view str)
227227 if (end < max_chars_) {
228228 // case1: str is in one segment
229229 // | [start]-->[end] |
230- std::copy (str.begin (), str.end (), &chars_[start]);
230+ // std::copy(str.begin(), str.end(), &chars_[start]);
231+ str.copy (&chars_[start], strlen);
231232 back_ = end;
232233
233234 } else {
@@ -236,13 +237,16 @@ void FixedSizeStringBuffer<SPACE>::push(std::string_view str)
236237 // |-->[end] [start]--->|
237238 size_t seg1 = max_chars_ - start;
238239 size_t seg2 = strlen - seg1;
239- back_ = seg2;
240240
241+ //
242+ // str.copy and std::copy take about the same time,
243+ // but syntax is cleaner with str.copy
244+ //
241245 // std::copy(&str[0], &str[seg1], &chars_[start]);
242246 // std::copy(&str[seg1], &str[strlen], &chars_[0]);
243-
244247 str.copy (&chars_[start], seg1);
245248 str.copy (&chars_[0 ], seg2, seg1);
249+ back_ = seg2;
246250
247251 }
248252 // use emplace object creation instead of ptr_.push_back(Pointer{start, strlen});
@@ -373,7 +377,7 @@ class fixed_size_string_buffer_utils {
373377
374378
375379 // https://stackoverflow.com/questions/39262323/print-a-string-variable-with-its-special-characters
376- static wchar_t escaped (char const ch) {
380+ static wchar_t escaped (const char ch) {
377381
378382 // from https://en.wikipedia.org/wiki/ASCII#Control_code_chart
379383 static const std::unordered_map<int , wchar_t > k_escapes =
0 commit comments