diff --git a/internal/tlcodegen/test/gen/cases_cpp/__meta/details.cpp b/internal/tlcodegen/test/gen/cases_cpp/__meta/details.cpp index 23a13c3f..12dedd0b 100644 --- a/internal/tlcodegen/test/gen/cases_cpp/__meta/details.cpp +++ b/internal/tlcodegen/test/gen/cases_cpp/__meta/details.cpp @@ -21,24 +21,27 @@ namespace { } tl2::meta::tl_item tl2::meta::get_item_by_name(std::string &&s) { - if (items.items.count(s)) { - return items.items[s]; + auto item = items.items.find(s); + if (item != items.items.end()) { + return item->second; } throw std::runtime_error("no item with such name + \"" + s + "\""); } void tl2::meta::set_create_object_by_name(std::string &&s, std::function()>&& gen) { - if (items.items.count(s)) { - items.items[s].create_object = gen; - return; + auto item = items.items.find(s); + if (item != items.items.end()) { + item->second.create_object = gen; + return; } throw std::runtime_error("no item with such name + \"" + s + "\""); } void tl2::meta::set_create_function_by_name(std::string &&s, std::function()>&& gen) { - if (items.items.count(s)) { - items.items[s].create_function = gen; - return; + auto item = items.items.find(s); + if (item != items.items.end()) { + item->second.create_function = gen; + return; } throw std::runtime_error("no item with such name + \"" + s + "\""); } diff --git a/internal/tlcodegen/test/gen/schema_cpp/__meta/details.cpp b/internal/tlcodegen/test/gen/schema_cpp/__meta/details.cpp index c5825737..2f731efb 100644 --- a/internal/tlcodegen/test/gen/schema_cpp/__meta/details.cpp +++ b/internal/tlcodegen/test/gen/schema_cpp/__meta/details.cpp @@ -21,24 +21,27 @@ namespace { } tl2::meta::tl_item tl2::meta::get_item_by_name(std::string &&s) { - if (items.items.count(s)) { - return items.items[s]; + auto item = items.items.find(s); + if (item != items.items.end()) { + return item->second; } throw std::runtime_error("no item with such name + \"" + s + "\""); } void tl2::meta::set_create_object_by_name(std::string &&s, std::function()>&& gen) { - if (items.items.count(s)) { - items.items[s].create_object = gen; - return; + auto item = items.items.find(s); + if (item != items.items.end()) { + item->second.create_object = gen; + return; } throw std::runtime_error("no item with such name + \"" + s + "\""); } void tl2::meta::set_create_function_by_name(std::string &&s, std::function()>&& gen) { - if (items.items.count(s)) { - items.items[s].create_function = gen; - return; + auto item = items.items.find(s); + if (item != items.items.end()) { + item->second.create_function = gen; + return; } throw std::runtime_error("no item with such name + \"" + s + "\""); } diff --git a/internal/tlcodegen/tlgen_cpp.go b/internal/tlcodegen/tlgen_cpp.go index 0a5d63ee..8bba2cd0 100644 --- a/internal/tlcodegen/tlgen_cpp.go +++ b/internal/tlcodegen/tlgen_cpp.go @@ -570,24 +570,27 @@ namespace { } tl2::meta::tl_item tl2::meta::get_item_by_name(std::string &&s) { - if (items.items.count(s)) { - return items.items[s]; + auto item = items.items.find(s); + if (item != items.items.end()) { + return item->second; } throw std::runtime_error("no item with such name + \"" + s + "\""); } void tl2::meta::set_create_object_by_name(std::string &&s, std::function()>&& gen) { - if (items.items.count(s)) { - items.items[s].create_object = gen; - return; + auto item = items.items.find(s); + if (item != items.items.end()) { + item->second.create_object = gen; + return; } throw std::runtime_error("no item with such name + \"" + s + "\""); } void tl2::meta::set_create_function_by_name(std::string &&s, std::function()>&& gen) { - if (items.items.count(s)) { - items.items[s].create_function = gen; - return; + auto item = items.items.find(s); + if (item != items.items.end()) { + item->second.create_function = gen; + return; } throw std::runtime_error("no item with such name + \"" + s + "\""); }