diff --git a/ext/ghoul b/ext/ghoul index 90240b2d5b..faa5727b46 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 90240b2d5bda2c910ea04c29bc9d4210dbd339b4 +Subproject commit faa5727b46cc52e5052af5465bf8c580e1a23528 diff --git a/include/openspace/properties/propertyowner.h b/include/openspace/properties/propertyowner.h index 77d4e6bdd9..251cd7c062 100644 --- a/include/openspace/properties/propertyowner.h +++ b/include/openspace/properties/propertyowner.h @@ -159,7 +159,7 @@ public: * \return If the Property cannot be found, `nullptr` is returned, otherwise the * pointer to the Property is returned */ - Property* property(const std::string& uri) const; + Property* property(std::string_view uri) const; /** * Retrieves a PropertyOwner identified by \p uri from this PropertyOwner. If \p uri @@ -173,7 +173,7 @@ public: * \return If the PropertyOwner cannot be found, `nullptr` is returned, otherwise the * pointer to the PropertyOwner is returned */ - PropertyOwner* propertyOwner(const std::string& uri) const; + PropertyOwner* propertyOwner(std::string_view uri) const; /** * Returns a uri for this PropertyOwner. This is created by looking up all the owners @@ -223,7 +223,7 @@ public: * \param identifier The identifier of the sub-owner that should be returned * \return The PropertyOwner with the given \p identifier, or `nullptr` */ - PropertyOwner* propertySubOwner(const std::string& identifier) const; + PropertyOwner* propertySubOwner(std::string_view identifier) const; /** * Returns `true` if this PropertyOwner owns a sub-owner with the provided diff --git a/include/openspace/query/query.h b/include/openspace/query/query.h index 9af26edcd7..f16c10b996 100644 --- a/include/openspace/query/query.h +++ b/include/openspace/query/query.h @@ -25,7 +25,7 @@ #ifndef __OPENSPACE_CORE___QUERY___H__ #define __OPENSPACE_CORE___QUERY___H__ -#include +#include #include namespace openspace { @@ -39,10 +39,10 @@ class IswaGroup; class ScreenSpaceRenderable; Scene* sceneGraph(); -SceneGraphNode* sceneGraphNode(const std::string& name); -const Renderable* renderable(const std::string& name); -properties::Property* property(const std::string& uri); -properties::PropertyOwner* propertyOwner(const std::string& uri); +SceneGraphNode* sceneGraphNode(std::string_view name); +const Renderable* renderable(std::string_view name); +properties::Property* property(std::string_view uri); +properties::PropertyOwner* propertyOwner(std::string_view uri); const std::vector& allProperties(); const std::vector& allPropertyOwners(); diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h index c319e89b86..9a052ae3a8 100644 --- a/include/openspace/scene/scene.h +++ b/include/openspace/scene/scene.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -115,7 +116,7 @@ public: * Return the scenegraph node with the specified name or `nullptr` if that name does * not exist. */ - SceneGraphNode* sceneGraphNode(const std::string& name) const; + SceneGraphNode* sceneGraphNode(std::string_view name) const; /** * Add a node and all its children to the scene. @@ -137,11 +138,6 @@ public: */ const std::vector& allSceneGraphNodes() const; - /** - * Returns a map from identifier to scene graph node. - */ - const std::unordered_map& nodesByIdentifier() const; - /** * Load a scene graph node from a dictionary and return it. */ @@ -268,7 +264,6 @@ private: */ void propertyPushProfileValueToLua(ghoul::lua::LuaState& L, const std::string& value); - /** * Update dependencies. */ @@ -278,7 +273,11 @@ private: std::unique_ptr _camera; std::vector _topologicallySortedNodes; std::vector _circularNodes; - std::unordered_map _nodesByIdentifier; + std::unordered_map< + std::string, SceneGraphNode*, + transparent_string_hash, + std::equal_to<> + > _nodesByIdentifier; bool _dirtyNodeRegistry = false; SceneGraphNode _rootNode; std::unique_ptr _initializer; diff --git a/src/properties/propertyowner.cpp b/src/properties/propertyowner.cpp index b48ff5d56c..1b9f13f3d3 100644 --- a/src/properties/propertyowner.cpp +++ b/src/properties/propertyowner.cpp @@ -105,7 +105,7 @@ std::vector PropertyOwner::subownersRecursive() const { return subowners; } -Property* PropertyOwner::property(const std::string& uri) const { +Property* PropertyOwner::property(std::string_view uri) const { auto it = std::find_if( _properties.begin(), _properties.end(), @@ -121,8 +121,8 @@ Property* PropertyOwner::property(const std::string& uri) const { return nullptr; } else { - const std::string ownerName = uri.substr(0, ownerSeparator); - const std::string propertyName = uri.substr(ownerSeparator + 1); + const std::string_view ownerName = uri.substr(0, ownerSeparator); + const std::string_view propertyName = uri.substr(ownerSeparator + 1); PropertyOwner* owner = propertySubOwner(ownerName); if (!owner) { @@ -139,7 +139,7 @@ Property* PropertyOwner::property(const std::string& uri) const { } } -PropertyOwner* PropertyOwner::propertyOwner(const std::string& uri) const { +PropertyOwner* PropertyOwner::propertyOwner(std::string_view uri) const { PropertyOwner* directChild = propertySubOwner(uri); if (directChild) { return directChild; @@ -153,8 +153,8 @@ PropertyOwner* PropertyOwner::propertyOwner(const std::string& uri) const { return nullptr; } else { - const std::string parentName = uri.substr(0, ownerSeparator); - const std::string ownerName = uri.substr(ownerSeparator + 1); + const std::string_view parentName = uri.substr(0, ownerSeparator); + const std::string_view ownerName = uri.substr(ownerSeparator + 1); PropertyOwner* owner = propertySubOwner(parentName); return owner ? owner->propertyOwner(ownerName) : nullptr; @@ -205,7 +205,7 @@ const std::vector& PropertyOwner::propertySubOwners() const { return _subOwners; } -PropertyOwner* PropertyOwner::propertySubOwner(const std::string& identifier) const { +PropertyOwner* PropertyOwner::propertySubOwner(std::string_view identifier) const { std::vector::const_iterator it = std::find_if( _subOwners.begin(), _subOwners.end(), diff --git a/src/query/query.cpp b/src/query/query.cpp index 6df0a0a01a..6144197c3b 100644 --- a/src/query/query.cpp +++ b/src/query/query.cpp @@ -35,7 +35,7 @@ Scene* sceneGraph() { return global::renderEngine->scene(); } -SceneGraphNode* sceneGraphNode(const std::string& name) { +SceneGraphNode* sceneGraphNode(std::string_view name) { const Scene* graph = sceneGraph(); if (!graph) { return nullptr; @@ -43,7 +43,7 @@ SceneGraphNode* sceneGraphNode(const std::string& name) { return graph->sceneGraphNode(name); } -const Renderable* renderable(const std::string& name) { +const Renderable* renderable(std::string_view name) { SceneGraphNode* node = sceneGraphNode(name); if (!node) { return nullptr; @@ -51,12 +51,12 @@ const Renderable* renderable(const std::string& name) { return node->renderable(); } -properties::Property* property(const std::string& uri) { +properties::Property* property(std::string_view uri) { properties::Property* property = global::rootPropertyOwner->property(uri); return property; } -properties::PropertyOwner* propertyOwner(const std::string& uri) { +properties::PropertyOwner* propertyOwner(std::string_view uri) { properties::PropertyOwner* property = global::rootPropertyOwner->propertyOwner(uri); return property; } diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index d07b3158e7..13673c0fee 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -524,10 +524,6 @@ void Scene::render(const RenderData& data, RendererTasks& tasks) { } } -const std::unordered_map& Scene::nodesByIdentifier() const { - return _nodesByIdentifier; -} - SceneGraphNode* Scene::root() { return &_rootNode; } @@ -536,7 +532,7 @@ const SceneGraphNode* Scene::root() const { return &_rootNode; } -SceneGraphNode* Scene::sceneGraphNode(const std::string& name) const { +SceneGraphNode* Scene::sceneGraphNode(std::string_view name) const { const auto it = _nodesByIdentifier.find(name); if (it != _nodesByIdentifier.end()) { return it->second;