File tree Expand file tree Collapse file tree 4 files changed +8
-8
lines changed
Expand file tree Collapse file tree 4 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ const T& ColumnEnum<T>::At(size_t n) const {
4444}
4545
4646template <typename T>
47- const std::string ColumnEnum<T>::NameAt(size_t n) const {
47+ std::string_view ColumnEnum<T>::NameAt(size_t n) const {
4848 return type_->As <EnumType>()->GetEnumName (data_.at (n));
4949}
5050
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ class ColumnEnum : public Column {
1919
2020 // / Returns element at given row number.
2121 const T& At (size_t n) const ;
22- const std::string NameAt (size_t n) const ;
22+ std::string_view NameAt (size_t n) const ;
2323
2424 // / Returns element at given row number.
2525 const T& operator [] (size_t n) const ;
@@ -38,7 +38,7 @@ class ColumnEnum : public Column {
3838 // / Saves column data to output stream.
3939 void SaveBody (OutputStream* output) override ;
4040
41- // / Clear column data .
41+ // / Clear column data.
4242 void Clear () override ;
4343
4444 // / Returns count of rows in the column.
Original file line number Diff line number Diff line change @@ -259,8 +259,8 @@ std::string DecimalType::GetName() const {
259259
260260EnumType::EnumType (Type::Code type, const std::vector<EnumItem>& items) : Type(type) {
261261 for (const auto & item : items) {
262- value_to_name_[item. second ] = item. first ;
263- name_to_value_ [item.first ] = item. second ;
262+ auto result = name_to_value_. insert (item) ;
263+ value_to_name_ [item.second ] = result. first -> first ;
264264 }
265265}
266266
@@ -291,7 +291,7 @@ std::string EnumType::GetName() const {
291291 return result;
292292}
293293
294- const std::string& EnumType::GetEnumName (int16_t value) const {
294+ std::string_view EnumType::GetEnumName (int16_t value) const {
295295 return value_to_name_.at (value);
296296}
297297
Original file line number Diff line number Diff line change @@ -212,13 +212,13 @@ class EnumType : public Type {
212212 std::string GetName () const ;
213213
214214 // / Methods to work with enum types.
215- const std::string& GetEnumName (int16_t value) const ;
215+ std::string_view GetEnumName (int16_t value) const ;
216216 int16_t GetEnumValue (const std::string& name) const ;
217217 bool HasEnumName (const std::string& name) const ;
218218 bool HasEnumValue (int16_t value) const ;
219219
220220private:
221- using ValueToNameType = std::map<int16_t , std::string >;
221+ using ValueToNameType = std::map<int16_t , std::string_view >;
222222 using NameToValueType = std::map<std::string, int16_t >;
223223 using ValueToNameIterator = ValueToNameType::const_iterator;
224224
You can’t perform that action at this time.
0 commit comments