diff options
-rw-r--r-- | Jamroot.jam | 1 | ||||
-rw-r--r-- | slicer/db/sqlInsertSerializer.cpp | 14 | ||||
-rw-r--r-- | slicer/db/sqlInsertSerializer.h | 14 | ||||
-rw-r--r-- | slicer/db/sqlSelectDeserializer.cpp | 10 | ||||
-rw-r--r-- | slicer/db/sqlSelectDeserializer.h | 8 | ||||
-rw-r--r-- | slicer/db/sqlUpdateSerializer.cpp | 8 | ||||
-rw-r--r-- | slicer/db/sqlUpdateSerializer.h | 8 | ||||
-rw-r--r-- | slicer/json/serializer.cpp | 4 | ||||
-rw-r--r-- | slicer/json/serializer.h | 4 | ||||
-rw-r--r-- | slicer/slicer/modelPartsTypes.cpp | 2 | ||||
-rw-r--r-- | slicer/test/compilation.cpp | 3 | ||||
-rw-r--r-- | slicer/tool/parser.cpp | 4 | ||||
-rw-r--r-- | slicer/tool/parser.h | 4 | ||||
-rw-r--r-- | slicer/xml/serializer.cpp | 16 | ||||
-rw-r--r-- | slicer/xml/serializer.h | 16 |
15 files changed, 59 insertions, 57 deletions
diff --git a/Jamroot.jam b/Jamroot.jam index 11ef158..38ee232 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -23,6 +23,7 @@ project <toolset>tidy:<checkxx>misc-* <toolset>tidy:<checkxx>modernize-* <toolset>tidy:<checkxx>hicpp-* + <toolset>tidy:<checkxx>performance-* ; build-project slicer ; diff --git a/slicer/db/sqlInsertSerializer.cpp b/slicer/db/sqlInsertSerializer.cpp index 6d02212..8890cc3 100644 --- a/slicer/db/sqlInsertSerializer.cpp +++ b/slicer/db/sqlInsertSerializer.cpp @@ -34,14 +34,14 @@ namespace Slicer { } void - SqlInsertSerializer::SerializeObject(Slicer::ModelPartPtr mp) const + SqlInsertSerializer::SerializeObject(const Slicer::ModelPartPtr & mp) const { auto ins = createInsert(mp); bindObjectAndExecute(mp, ins.get()); } void - SqlInsertSerializer::SerializeSequence(Slicer::ModelPartPtr mp) const + SqlInsertSerializer::SerializeSequence(const Slicer::ModelPartPtr & mp) const { auto ins = createInsert(mp->GetContainedModelPart()); mp->OnEachChild([&ins, this](const std::string &, ModelPartPtr cmp, const HookCommon *) { @@ -50,7 +50,7 @@ namespace Slicer { } void - SqlInsertSerializer::bindObjectAndExecute(Slicer::ModelPartPtr cmp, DB::ModifyCommand * ins) const + SqlInsertSerializer::bindObjectAndExecute(const Slicer::ModelPartPtr & cmp, DB::ModifyCommand * ins) const { int paramNo = 0; cmp->OnEachChild(std::bind(&SqlInsertSerializer::bindObjectAndExecuteField, this, std::ref(paramNo), ins, _2, _3)); @@ -87,7 +87,7 @@ namespace Slicer { }; void - SqlFetchIdInsertSerializer::bindObjectAndExecute(Slicer::ModelPartPtr cmp, DB::ModifyCommand * ins) const + SqlFetchIdInsertSerializer::bindObjectAndExecute(const Slicer::ModelPartPtr & cmp, DB::ModifyCommand * ins) const { SqlAutoIdInsertSerializer::bindObjectAndExecute(cmp, ins); cmp->OnEachChild([this](const std::string &, ModelPartPtr cmp, const HookCommon * h) { @@ -98,7 +98,7 @@ namespace Slicer { } void - SqlInsertSerializer::bindObjectAndExecuteField(int & paramNo, DB::ModifyCommand * ins, Slicer::ModelPartPtr cmp, const HookCommon * h) const + SqlInsertSerializer::bindObjectAndExecuteField(int & paramNo, DB::ModifyCommand * ins, const Slicer::ModelPartPtr & cmp, const HookCommon * h) const { if (isBind(h)) { if (!cmp->GetValue(SqlBinder(*ins, paramNo))) { @@ -109,7 +109,7 @@ namespace Slicer { } void - SqlAutoIdInsertSerializer::bindObjectAndExecuteField(int & paramNo, DB::ModifyCommand * ins, Slicer::ModelPartPtr cmp, const HookCommon * h) const + SqlAutoIdInsertSerializer::bindObjectAndExecuteField(int & paramNo, DB::ModifyCommand * ins, const Slicer::ModelPartPtr & cmp, const HookCommon * h) const { if (isNotAuto(h)) { SqlInsertSerializer::bindObjectAndExecuteField(paramNo, ins, cmp, h); @@ -117,7 +117,7 @@ namespace Slicer { } DB::ModifyCommandPtr - SqlInsertSerializer::createInsert(Slicer::ModelPartPtr mp) const + SqlInsertSerializer::createInsert(const Slicer::ModelPartPtr & mp) const { AdHoc::Buffer insert; insert.appendbf("INSERT INTO %s(", tableName); diff --git a/slicer/db/sqlInsertSerializer.h b/slicer/db/sqlInsertSerializer.h index fcabb4a..d3e2215 100644 --- a/slicer/db/sqlInsertSerializer.h +++ b/slicer/db/sqlInsertSerializer.h @@ -14,12 +14,12 @@ namespace Slicer { virtual void Serialize(Slicer::ModelPartForRootPtr) override; protected: - void SerializeObject(Slicer::ModelPartPtr) const; - void SerializeSequence(Slicer::ModelPartPtr) const; - DB::ModifyCommandPtr createInsert(Slicer::ModelPartPtr) const; + void SerializeObject(const Slicer::ModelPartPtr &) const; + void SerializeSequence(const Slicer::ModelPartPtr &) const; + DB::ModifyCommandPtr createInsert(const Slicer::ModelPartPtr &) const; virtual void createInsertField(int & fieldNo, AdHoc::Buffer & insert, const std::string & name, const HookCommon * h) const; - virtual void bindObjectAndExecute(Slicer::ModelPartPtr, DB::ModifyCommand *) const; - virtual void bindObjectAndExecuteField(int & paramNo, DB::ModifyCommand *, Slicer::ModelPartPtr, const HookCommon *) const; + virtual void bindObjectAndExecute(const Slicer::ModelPartPtr &, DB::ModifyCommand *) const; + virtual void bindObjectAndExecuteField(int & paramNo, DB::ModifyCommand *, const Slicer::ModelPartPtr &, const HookCommon *) const; DB::Connection * const connection; const std::string tableName; @@ -32,7 +32,7 @@ namespace Slicer { protected: virtual void createInsertField(int & fieldNo, AdHoc::Buffer & insert, const std::string & name, const HookCommon * h) const; - virtual void bindObjectAndExecuteField(int & paramNo, DB::ModifyCommand *, Slicer::ModelPartPtr, const HookCommon *) const; + virtual void bindObjectAndExecuteField(int & paramNo, DB::ModifyCommand *, const Slicer::ModelPartPtr &, const HookCommon *) const; }; class DLL_PUBLIC SqlFetchIdInsertSerializer : public SqlAutoIdInsertSerializer { @@ -41,7 +41,7 @@ namespace Slicer { SqlFetchIdInsertSerializer(const P & ... p) : SqlAutoIdInsertSerializer(p...) { } protected: - virtual void bindObjectAndExecute(Slicer::ModelPartPtr, DB::ModifyCommand *) const; + virtual void bindObjectAndExecute(const Slicer::ModelPartPtr &, DB::ModifyCommand *) const; }; } diff --git a/slicer/db/sqlSelectDeserializer.cpp b/slicer/db/sqlSelectDeserializer.cpp index c4ea0d5..d56c7f2 100644 --- a/slicer/db/sqlSelectDeserializer.cpp +++ b/slicer/db/sqlSelectDeserializer.cpp @@ -35,7 +35,7 @@ namespace Slicer { } void - SqlSelectDeserializer::DeserializeSimple(Slicer::ModelPartPtr mp) + SqlSelectDeserializer::DeserializeSimple(const Slicer::ModelPartPtr & mp) { if (!cmd->fetch()) { if (!mp->IsOptional()) { @@ -55,16 +55,16 @@ namespace Slicer { } void - SqlSelectDeserializer::DeserializeSequence(Slicer::ModelPartPtr mp) + SqlSelectDeserializer::DeserializeSequence(const Slicer::ModelPartPtr & omp) { - mp = mp->GetAnonChild(); + auto mp = omp->GetAnonChild(); while (cmd->fetch()) { DeserializeRow(mp); } } void - SqlSelectDeserializer::DeserializeObject(Slicer::ModelPartPtr mp) + SqlSelectDeserializer::DeserializeObject(const Slicer::ModelPartPtr & mp) { if (!cmd->fetch()) { if (!mp->IsOptional()) { @@ -80,7 +80,7 @@ namespace Slicer { } void - SqlSelectDeserializer::DeserializeRow(Slicer::ModelPartPtr mp) + SqlSelectDeserializer::DeserializeRow(const Slicer::ModelPartPtr & mp) { auto rmp = mp->GetAnonChild(); if (rmp) { diff --git a/slicer/db/sqlSelectDeserializer.h b/slicer/db/sqlSelectDeserializer.h index 96c7334..736bb11 100644 --- a/slicer/db/sqlSelectDeserializer.h +++ b/slicer/db/sqlSelectDeserializer.h @@ -13,10 +13,10 @@ namespace Slicer { virtual void Deserialize(Slicer::ModelPartForRootPtr) override; protected: - void DLL_PRIVATE DeserializeSimple(Slicer::ModelPartPtr); - void DLL_PRIVATE DeserializeObject(Slicer::ModelPartPtr); - void DLL_PRIVATE DeserializeSequence(Slicer::ModelPartPtr); - void DLL_PRIVATE DeserializeRow(Slicer::ModelPartPtr); + void DLL_PRIVATE DeserializeSimple(const Slicer::ModelPartPtr &); + void DLL_PRIVATE DeserializeObject(const Slicer::ModelPartPtr &); + void DLL_PRIVATE DeserializeSequence(const Slicer::ModelPartPtr &); + void DLL_PRIVATE DeserializeRow(const Slicer::ModelPartPtr &); DB::SelectCommand * cmd; unsigned int columnCount; diff --git a/slicer/db/sqlUpdateSerializer.cpp b/slicer/db/sqlUpdateSerializer.cpp index 0153fbf..bf690dc 100644 --- a/slicer/db/sqlUpdateSerializer.cpp +++ b/slicer/db/sqlUpdateSerializer.cpp @@ -33,14 +33,14 @@ namespace Slicer { } void - SqlUpdateSerializer::SerializeObject(Slicer::ModelPartPtr mp) const + SqlUpdateSerializer::SerializeObject(const Slicer::ModelPartPtr & mp) const { auto ins = createUpdate(mp); bindObjectAndExecute(mp, ins.get()); } void - SqlUpdateSerializer::SerializeSequence(Slicer::ModelPartPtr mp) const + SqlUpdateSerializer::SerializeSequence(const Slicer::ModelPartPtr & mp) const { auto ins = createUpdate(mp->GetContainedModelPart()); mp->OnEachChild([&ins](const std::string &, ModelPartPtr cmp, const HookCommon *) { @@ -49,7 +49,7 @@ namespace Slicer { } void - SqlUpdateSerializer::bindObjectAndExecute(Slicer::ModelPartPtr cmp, DB::ModifyCommand * upd) + SqlUpdateSerializer::bindObjectAndExecute(const Slicer::ModelPartPtr & cmp, DB::ModifyCommand * upd) { int paramNo = 0; cmp->OnEachChild([&upd, ¶mNo](const std::string &, ModelPartPtr cmp, const HookCommon * h) { @@ -71,7 +71,7 @@ namespace Slicer { } DB::ModifyCommandPtr - SqlUpdateSerializer::createUpdate(Slicer::ModelPartPtr mp) const + SqlUpdateSerializer::createUpdate(const Slicer::ModelPartPtr & mp) const { AdHoc::Buffer update; update.appendbf("UPDATE %s SET ", tableName); diff --git a/slicer/db/sqlUpdateSerializer.h b/slicer/db/sqlUpdateSerializer.h index d142c04..7c451b2 100644 --- a/slicer/db/sqlUpdateSerializer.h +++ b/slicer/db/sqlUpdateSerializer.h @@ -13,10 +13,10 @@ namespace Slicer { virtual void Serialize(Slicer::ModelPartForRootPtr) override; protected: - void SerializeObject(Slicer::ModelPartPtr) const; - void SerializeSequence(Slicer::ModelPartPtr) const; - DB::ModifyCommandPtr createUpdate(Slicer::ModelPartPtr) const; - static void bindObjectAndExecute(Slicer::ModelPartPtr, DB::ModifyCommand *); + void SerializeObject(const Slicer::ModelPartPtr &) const; + void SerializeSequence(const Slicer::ModelPartPtr &) const; + DB::ModifyCommandPtr createUpdate(const Slicer::ModelPartPtr &) const; + static void bindObjectAndExecute(const Slicer::ModelPartPtr &, DB::ModifyCommand *); DB::Connection * const connection; const std::string tableName; diff --git a/slicer/json/serializer.cpp b/slicer/json/serializer.cpp index 8c41550..e921573 100644 --- a/slicer/json/serializer.cpp +++ b/slicer/json/serializer.cpp @@ -194,7 +194,7 @@ namespace Slicer { }; void - JsonSerializer::ModelTreeIterateSeq(json::Value * n, ModelPartPtr mp) + JsonSerializer::ModelTreeIterateSeq(json::Value * n, const ModelPartPtr & mp) { if (!mp->HasValue()) { return; @@ -205,7 +205,7 @@ namespace Slicer { } void - JsonSerializer::ModelTreeIterateDictObj(json::Value * n, ModelPartPtr mp) + JsonSerializer::ModelTreeIterateDictObj(json::Value * n, const ModelPartPtr & mp) { if (!mp->HasValue()) { return; diff --git a/slicer/json/serializer.h b/slicer/json/serializer.h index b1a97b3..64679ed 100644 --- a/slicer/json/serializer.h +++ b/slicer/json/serializer.h @@ -9,8 +9,8 @@ namespace Slicer { class JsonSerializer : public Serializer { protected: static void ModelTreeIterate(json::Value *, const std::string &, ModelPartPtr mp); - static void ModelTreeIterateDictObj(json::Value *, ModelPartPtr mp); - static void ModelTreeIterateSeq(json::Value *, ModelPartPtr mp); + static void ModelTreeIterateDictObj(json::Value *, const ModelPartPtr & mp); + static void ModelTreeIterateSeq(json::Value *, const ModelPartPtr & mp); static void ModelTreeIterateRoot(json::Value *, ModelPartPtr mp); }; diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp index 0f95c1f..ac95164 100644 --- a/slicer/slicer/modelPartsTypes.cpp +++ b/slicer/slicer/modelPartsTypes.cpp @@ -267,7 +267,7 @@ namespace Slicer { ModelPartType ModelPartForStreamBase::GetType() const { return mpt_Sequence; } bool ModelPartForStreamBase::HasValue() const { return true; } // Stream Roots - ModelPartForStreamRootBase::ModelPartForStreamRootBase(ModelPartPtr mp) : ModelPartForRootBase(mp) { } + ModelPartForStreamRootBase::ModelPartForStreamRootBase(ModelPartPtr mp) : ModelPartForRootBase(std::move(mp)) { } // NOLINTNEXTLINE(hicpp-no-array-decay) void ModelPartForStreamRootBase::Write(Ice::OutputStream&) const { throw InvalidStreamOperation(__FUNCTION__); } // NOLINTNEXTLINE(hicpp-no-array-decay) diff --git a/slicer/test/compilation.cpp b/slicer/test/compilation.cpp index e6e9d02..445e867 100644 --- a/slicer/test/compilation.cpp +++ b/slicer/test/compilation.cpp @@ -35,8 +35,9 @@ BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_class ) BOOST_REQUIRE_EQUAL(mpp.get(), mpp->GetContainedModelPart().get()); } +static void -hookHandler(std::vector<std::string> * names, const std::string & name, Slicer::ModelPartPtr mpp, const Slicer::HookCommon * h) +hookHandler(std::vector<std::string> * names, const std::string & name, const Slicer::ModelPartPtr & mpp, const Slicer::HookCommon * h) { names->push_back(name); BOOST_REQUIRE(mpp); diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp index ca92390..9aa27cd 100644 --- a/slicer/tool/parser.cpp +++ b/slicer/tool/parser.cpp @@ -23,7 +23,7 @@ namespace Slicer { } void - Slicer::defineConversions(Slice::DataMemberPtr dm) const + Slicer::defineConversions(const Slice::DataMemberPtr & dm) const { if (!cpp) { return; } @@ -239,7 +239,7 @@ namespace Slicer { } void - Slicer::visitComplexDataMembers(Slice::ConstructedPtr it, const Slice::DataMemberList & dataMembers) const + Slicer::visitComplexDataMembers(const Slice::ConstructedPtr & it, const Slice::DataMemberList & dataMembers) const { if (!cpp) { return; } diff --git a/slicer/tool/parser.h b/slicer/tool/parser.h index 139cd32..b9474d3 100644 --- a/slicer/tool/parser.h +++ b/slicer/tool/parser.h @@ -56,9 +56,9 @@ namespace Slicer { std::string getBasicModelPart(const Slice::TypePtr & type) const; void defineMODELPART(const std::string & type, const Slice::TypePtr & stype, const Slice::StringList & metadata) const; - void visitComplexDataMembers(Slice::ConstructedPtr t, const Slice::DataMemberList &) const; + void visitComplexDataMembers(const Slice::ConstructedPtr & t, const Slice::DataMemberList &) const; - void defineConversions(Slice::DataMemberPtr dm) const; + void defineConversions(const Slice::DataMemberPtr & dm) const; void defineRoot(const std::string & type, const std::string & name, const Slice::TypePtr & stype) const; bool hasMetadata(const std::list<std::string> & metadata) const; diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp index dbd0af1..6d9a60d 100644 --- a/slicer/xml/serializer.cpp +++ b/slicer/xml/serializer.cpp @@ -182,7 +182,7 @@ namespace Slicer { }; void - XmlDeserializer::DocumentTreeIterateDictAttrs(const xmlpp::Element::const_AttributeList & attrs, ModelPartPtr dict) + XmlDeserializer::DocumentTreeIterateDictAttrs(const xmlpp::Element::const_AttributeList & attrs, const ModelPartPtr & dict) { for (const auto & attr : attrs) { auto emp = dict->GetAnonChild(); @@ -198,7 +198,7 @@ namespace Slicer { } void - XmlDeserializer::DocumentTreeIterateDictElements(const xmlpp::Element * element, ModelPartPtr dict) + XmlDeserializer::DocumentTreeIterateDictElements(const xmlpp::Element * element, const ModelPartPtr & dict) { auto node = element->get_first_child(); while (node) { @@ -251,7 +251,7 @@ namespace Slicer { } void - XmlDeserializer::DocumentTreeIterate(const xmlpp::Node * node, ModelPartPtr mp) + XmlDeserializer::DocumentTreeIterate(const xmlpp::Node * node, const ModelPartPtr & mp) { while (node) { if (auto element = dynamic_cast<const xmlpp::Element *>(node)) { @@ -297,13 +297,13 @@ namespace Slicer { } void - XmlDeserializer::DocumentTreeIterate(const xmlpp::Document * doc, ModelPartPtr mp) + XmlDeserializer::DocumentTreeIterate(const xmlpp::Document * doc, const ModelPartPtr & mp) { DocumentTreeIterate(doc->get_root_node(), mp); } void - XmlSerializer::ModelTreeIterate(xmlpp::Element * n, const std::string & name, ModelPartPtr mp, const HookCommon * hp, const ElementCreator & ec) + XmlSerializer::ModelTreeIterate(xmlpp::Element * n, const std::string & name, const ModelPartPtr & mp, const HookCommon * hp, const ElementCreator & ec) { if (name.empty()) { return; @@ -332,7 +332,7 @@ namespace Slicer { } void - XmlSerializer::ModelTreeIterateDictAttrs(xmlpp::Element * element, ModelPartPtr dict) + XmlSerializer::ModelTreeIterateDictAttrs(xmlpp::Element * element, const ModelPartPtr & dict) { dict->OnEachChild([element](const auto &, const auto & mp, const auto &) { if (mp->HasValue()) { @@ -344,7 +344,7 @@ namespace Slicer { } void - XmlSerializer::ModelTreeIterateDictElements(xmlpp::Element * element, ModelPartPtr dict) + XmlSerializer::ModelTreeIterateDictElements(xmlpp::Element * element, const ModelPartPtr & dict) { dict->OnEachChild([element](const auto &, const auto & mp, const auto &) { if (mp->HasValue()) { @@ -375,7 +375,7 @@ namespace Slicer { } void - XmlSerializer::ModelTreeIterateRoot(xmlpp::Document * doc, const std::string & name, ModelPartPtr mp) + XmlSerializer::ModelTreeIterateRoot(xmlpp::Document * doc, const std::string & name, const ModelPartPtr & mp) { ModelTreeProcessElement(doc->create_root_node(name), mp, defaultElementCreator); } diff --git a/slicer/xml/serializer.h b/slicer/xml/serializer.h index 1ab2ec2..d2220ef 100644 --- a/slicer/xml/serializer.h +++ b/slicer/xml/serializer.h @@ -13,13 +13,13 @@ namespace Slicer { class DLL_PUBLIC XmlSerializer : public Serializer { protected: typedef std::function<xmlpp::Element *(xmlpp::Element *, const Glib::ustring &)> ElementCreator; - static void ModelTreeIterate(xmlpp::Element *, const std::string &, ModelPartPtr mp, const HookCommon * hp, const ElementCreator &); - static void ModelTreeIterateRoot(xmlpp::Document *, const std::string &, ModelPartPtr mp); + static void ModelTreeIterate(xmlpp::Element *, const std::string &, const ModelPartPtr & mp, const HookCommon * hp, const ElementCreator &); + static void ModelTreeIterateRoot(xmlpp::Document *, const std::string &, const ModelPartPtr & mp); protected: static void ModelTreeProcessElement(const CurrentElementCreator &, ModelPartPtr mp, const ElementCreator &); - static void ModelTreeIterateDictAttrs(xmlpp::Element * element, ModelPartPtr dict); - static void ModelTreeIterateDictElements(xmlpp::Element * element, ModelPartPtr dict); + static void ModelTreeIterateDictAttrs(xmlpp::Element * element, const ModelPartPtr & dict); + static void ModelTreeIterateDictElements(xmlpp::Element * element, const ModelPartPtr & dict); }; class DLL_PUBLIC XmlStreamSerializer : public XmlSerializer { @@ -54,11 +54,11 @@ namespace Slicer { class DLL_PUBLIC XmlDeserializer : public Deserializer { protected: - static void DocumentTreeIterate(const xmlpp::Node * node, ModelPartPtr mp); + static void DocumentTreeIterate(const xmlpp::Node * node, const ModelPartPtr & mp); static void DocumentTreeIterateElement(const xmlpp::Element * element, ModelPartPtr mp, const ChildRef & c); - static void DocumentTreeIterate(const xmlpp::Document * doc, ModelPartPtr mp); - static void DocumentTreeIterateDictAttrs(const xmlpp::Element::const_AttributeList & attrs, ModelPartPtr dict); - static void DocumentTreeIterateDictElements(const xmlpp::Element * parent, ModelPartPtr dict); + static void DocumentTreeIterate(const xmlpp::Document * doc, const ModelPartPtr & mp); + static void DocumentTreeIterateDictAttrs(const xmlpp::Element::const_AttributeList & attrs, const ModelPartPtr & dict); + static void DocumentTreeIterateDictElements(const xmlpp::Element * parent, const ModelPartPtr & dict); }; class DLL_PUBLIC XmlStreamDeserializer : public XmlDeserializer { |