From b8055fa6f4768afad8a133ff565d5e8fbf5faed4 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 13 Sep 2023 09:25:22 -0500 Subject: [PATCH] App/Toponaming: Minor code cleanup --- src/App/Document.cpp | 1 + src/App/Document.h | 13 ++++++------- src/App/PropertyContainer.cpp | 17 +++++++++-------- src/App/private/DocumentP.h | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 9b9613d7f8..22768f46fe 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -1056,6 +1056,7 @@ std::pair Document::addStringHasher(const StringHasherRef & hasher) co StringHasherRef Document::getStringHasher(int idx) const { if(idx<0) { + return d->Hasher; return d->Hasher; } StringHasherRef hasher; diff --git a/src/App/Document.h b/src/App/Document.h index ec8bfbd331..4e4d65e042 100644 --- a/src/App/Document.h +++ b/src/App/Document.h @@ -51,7 +51,7 @@ namespace App class Application; class Transaction; class StringHasher; - typedef Base::Reference StringHasherRef; + using StringHasherRef = Base::Reference; } namespace App @@ -476,11 +476,11 @@ public: /** Called by property during properly save its containing StringHasher * * @param hasher: the input hasher - * @return Returns a pair. Boolean member indicate if the - * StringHasher has been saved before. The Integer is the hasher index. + * @return Returns a pair. The boolean indicates if the + * StringHasher has been saved before. The integer is the hasher index. * * The StringHasher object is designed to be shared among multiple objects. - * So, we must not save duplicate copies of the same hasher. And must be + * We must not save duplicate copies of the same hasher, and must be * able to restore with the same sharing relationship. This function returns * whether the hasher has been saved before by other objects, and the index * of the hasher. If the hasher has not been saved before, the object must @@ -495,9 +495,8 @@ public: * * @return Return the resulting string hasher. * - * The caller is responsible to restore the hasher itself if it is the first - * owner of the hasher, i.e. return addStringHasher() returns true during - * save + * The caller is responsible for restoring the hasher if the caller is the first + * owner of the hasher, i.e. if addStringHasher() returns true during save. */ StringHasherRef getStringHasher(int index=-1) const; diff --git a/src/App/PropertyContainer.cpp b/src/App/PropertyContainer.cpp index ce320e55a4..e4f76e92aa 100644 --- a/src/App/PropertyContainer.cpp +++ b/src/App/PropertyContainer.cpp @@ -221,16 +221,16 @@ PropertyData PropertyContainer::propertyData; void PropertyContainer::beforeSave() const { - std::map Map; + std::map Map; getPropertyMap(Map); - for(auto &entry : Map) { + for (auto& entry : Map) { auto prop = entry.second; - if(!prop->testStatus(Property::PropDynamic) - && (prop->testStatus(Property::Transient) || - getPropertyType(prop) & Prop_Transient)) - { + if (!prop->testStatus(Property::PropDynamic) + && (prop->testStatus(Property::Transient) + || ((getPropertyType(prop) & Prop_Transient) != 0))) { // Nothing - } else { + } + else { prop->beforeSave(); } } @@ -254,8 +254,9 @@ void PropertyContainer::Save (Base::Writer &writer) const { transients.push_back(prop); it = Map.erase(it); - }else + } else { ++it; + } } writer.incInd(); // indentation for 'Properties Count' diff --git a/src/App/private/DocumentP.h b/src/App/private/DocumentP.h index 3246459f53..a85d90af50 100644 --- a/src/App/private/DocumentP.h +++ b/src/App/private/DocumentP.h @@ -50,7 +50,7 @@ using Node = std::vector ; using Path = std::vector ; namespace App { -typedef boost::bimap HasherMap; +using HasherMap = boost::bimap; class Transaction; // Pimpl class