[glom] Use a std::unordered_set instead of a std::unordered_map with bool value.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Use a std::unordered_set instead of a std::unordered_map with bool value.
- Date: Sun, 6 Nov 2016 19:19:33 +0000 (UTC)
commit 223ba9f7eda66dac37eac55135b85c9dd84cc014
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Nov 6 11:52:44 2016 +0100
Use a std::unordered_set instead of a std::unordered_map with bool value.
glom/base_db_table_data.cc | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/glom/base_db_table_data.cc b/glom/base_db_table_data.cc
index 2056b6c..ff54e36 100644
--- a/glom/base_db_table_data.cc
+++ b/glom/base_db_table_data.cc
@@ -31,6 +31,8 @@
#include <iostream>
#include <glibmm/i18n.h>
+#include <unordered_set>
+
namespace Glom
{
@@ -88,7 +90,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
builder->set_table(m_table_name);
//Avoid specifying the same field twice:
- typedef std::unordered_map<Glib::ustring, bool, std::hash<std::string>> type_map_added;
+ typedef std::unordered_set<Glib::ustring, std::hash<std::string>> type_map_added;
type_map_added map_added;
auto params = Gnome::Gda::Set::create();
@@ -97,8 +99,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
const Glib::ustring field_name = layout_item->get_name();
if(!layout_item->get_has_relationship_name()) //TODO: Allow people to add a related record also by
entering new data in a related field of the related record.
{
- const auto iterFind = map_added.find(field_name);
- if(iterFind == map_added.end()) //If it was not added already
+ if (!map_added.count(field_name)) //If it was not added already.
{
Gnome::Gda::Value value;
@@ -171,7 +172,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
if(!value.is_null())
{
builder->add_field_value(field_name, value);
- map_added[field_name] = true;
+ map_added.emplace(field_name);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]