From 2a3bb62001965837a5af7371ccae227d6a7bfac2 Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 18 Jul 2017 18:01:50 +0100 Subject: [PATCH] Add efficient hasTag check to Package. Avoids copying the tags set each time to check for presence / absence of a particular tag. --- simgear/package/Package.cxx | 5 +++++ simgear/package/Package.hxx | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/simgear/package/Package.cxx b/simgear/package/Package.cxx index 17772f94..f802f6b3 100644 --- a/simgear/package/Package.cxx +++ b/simgear/package/Package.cxx @@ -268,6 +268,11 @@ string_set Package::tags() const { return m_tags; } + +bool Package::hasTag(const std::string& tag) const +{ + return m_tags.find(tag) != m_tags.end(); +} SGPropertyNode* Package::properties() const { diff --git a/simgear/package/Package.hxx b/simgear/package/Package.hxx index 544ffb5c..0c5daa6c 100644 --- a/simgear/package/Package.hxx +++ b/simgear/package/Package.hxx @@ -142,6 +142,13 @@ public: string_set tags() const; + /** + * @brief hasTag - efficently check if a tag is defined or not + * @param tag + * @return + */ + bool hasTag(const std::string& tag) const; + /** * download URLs for the package */