[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Andriy Andreykiv |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Fri, 3 Aug 2018 12:10:17 -0400 (EDT) |
branch: comparing_stored_objects_by_key
commit 0722a459811b9579e4f288457ad7faa7a467be26
Author: aa <address@hidden>
Date: Fri Aug 3 18:10:00 2018 +0200
readability improvements
---
src/dal_static_stored_objects.cc | 23 ++++++++++-------------
src/getfem/bgeot_convex.h | 7 ++-----
src/getfem/dal_naming_system.h | 10 ++++++----
3 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/src/dal_static_stored_objects.cc b/src/dal_static_stored_objects.cc
index fef41c6..5080355 100644
--- a/src/dal_static_stored_objects.cc
+++ b/src/dal_static_stored_objects.cc
@@ -194,22 +194,19 @@ static bool dal_static_stored_tab_valid__ = true;
pstatic_stored_object
search_stored_object_on_all_threads(pstatic_stored_object_key k)
{
auto& stored_objects = singleton<stored_object_tab>::instance();
- if (dal_static_stored_tab_valid__) {
- auto p = stored_objects.search_stored_object(k);
+ if (!dal_static_stored_tab_valid__) return nullptr;
+ auto p = stored_objects.search_stored_object(k);
+ if (p) return p;
+ if (num_threads() == 1) return nullptr;
+ for(size_t thread = 0; thread < getfem::num_threads(); thread++)
+ {
+ if (thread == this_thread()) continue;
+ auto& other_objects = singleton<stored_object_tab>::instance(thread);
+ p = other_objects.search_stored_object(k);
if (p) return p;
- else if (num_threads() > 1){
- for(size_t thread = 0; thread < getfem::num_threads(); thread++)
- {
- if (thread == this_thread()) continue;
- auto& other_objects = singleton<stored_object_tab>::instance(thread);
- p = other_objects.search_stored_object(k);
- if (p) return p;
- }
- }
- return nullptr;
}
return nullptr;
- }
+ }
std::pair<stored_object_tab::iterator, stored_object_tab::iterator>
iterators_of_object(
pstatic_stored_object o)
diff --git a/src/getfem/bgeot_convex.h b/src/getfem/bgeot_convex.h
index 58adc3c..1b100a5 100644
--- a/src/getfem/bgeot_convex.h
+++ b/src/getfem/bgeot_convex.h
@@ -186,8 +186,7 @@ namespace bgeot {
pconvex_structure p;
bool compare(const static_stored_object_key &oo) const override {
auto &o = dynamic_cast<const special_convex_structure_key_ &>(oo);
- if (p < o.p) return true;
- return false;
+ return p < o.p;
}
bool equal(const static_stored_object_key &oo) const override {
auto &o = dynamic_cast<const special_convex_structure_key_ &>(oo);
@@ -195,9 +194,7 @@ namespace bgeot {
auto pkey = dal::key_of_stored_object(p);
auto poo_key = dal::key_of_stored_object(o.p);
- if (*pkey != *poo_key) return false;
-
- return true;
+ return *pkey == *poo_key;
}
special_convex_structure_key_(pconvex_structure pp) : p(pp) {}
};
diff --git a/src/getfem/dal_naming_system.h b/src/getfem/dal_naming_system.h
index 9c66eb5..e06c1cc 100644
--- a/src/getfem/dal_naming_system.h
+++ b/src/getfem/dal_naming_system.h
@@ -90,13 +90,15 @@ namespace dal {
std::string name;
bool compare(const static_stored_object_key &oo) const override{
- auto &o = dynamic_cast<const method_key &>(oo);
- return name < o.name;
+ auto &o = dynamic_cast<const method_key &>(oo);
+ return name < o.name;
}
+
bool equal(const static_stored_object_key &oo) const override{
- auto &o = dynamic_cast<const method_key &>(oo);
- return name == o.name;
+ auto &o = dynamic_cast<const method_key &>(oo);
+ return name == o.name;
}
+
method_key(const std::string &name_) : name(name_) {}
};