diff options
author | Hans Goudey <h.goudey@me.com> | 2022-08-30 02:11:37 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-08-30 02:11:37 +0300 |
commit | 5ae3fa50e224700e5722ecbe641692776bba0567 (patch) | |
tree | 9b25ac2797ebee4c92ca082f4011df41b56e503d /source | |
parent | 6577d2df8ce3b1f9ace3e027868f7435e263edbc (diff) |
Cleanup: Remove misleading std::string reference binding
These functions that retrieve strings from assets return stringrefs.
Storing them as std::strings is unnecessary and relies on binding to
the const references.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/asset/intern/asset_indexer.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/editors/asset/intern/asset_indexer.cc b/source/blender/editors/asset/intern/asset_indexer.cc index 3cc3638c299..cc06fa80429 100644 --- a/source/blender/editors/asset/intern/asset_indexer.cc +++ b/source/blender/editors/asset/intern/asset_indexer.cc @@ -351,7 +351,7 @@ static void init_indexer_entry_from_value(FileIndexerEntry &indexer_entry, { indexer_entry.idcode = entry.get_idcode(); - const std::string &name = entry.get_name(); + const std::string name = entry.get_name(); BLI_strncpy( indexer_entry.datablock_info.name, name.c_str(), sizeof(indexer_entry.datablock_info.name)); @@ -359,19 +359,19 @@ static void init_indexer_entry_from_value(FileIndexerEntry &indexer_entry, indexer_entry.datablock_info.asset_data = asset_data; if (entry.has_description()) { - const std::string &description = entry.get_description(); - char *description_c_str = static_cast<char *>(MEM_mallocN(description.length() + 1, __func__)); - BLI_strncpy(description_c_str, description.c_str(), description.length() + 1); + const StringRefNull description = entry.get_description(); + char *description_c_str = static_cast<char *>(MEM_mallocN(description.size() + 1, __func__)); + BLI_strncpy(description_c_str, description.c_str(), description.size() + 1); asset_data->description = description_c_str; } if (entry.has_author()) { - const std::string &author = entry.get_author(); - char *author_c_str = static_cast<char *>(MEM_mallocN(author.length() + 1, __func__)); - BLI_strncpy(author_c_str, author.c_str(), author.length() + 1); + const StringRefNull author = entry.get_author(); + char *author_c_str = static_cast<char *>(MEM_mallocN(author.size() + 1, __func__)); + BLI_strncpy(author_c_str, author.c_str(), author.size() + 1); asset_data->author = author_c_str; } - const std::string &catalog_name = entry.get_catalog_name(); + const StringRefNull catalog_name = entry.get_catalog_name(); BLI_strncpy(asset_data->catalog_simple_name, catalog_name.c_str(), sizeof(asset_data->catalog_simple_name)); |