From 415a68cbe8e68f909245b33f63af13e399a849f5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 10 Feb 2025 15:33:57 -0500 Subject: Avoid potentially returning a reference to a local This case shouldn't happen anyway since it's handled at the caller, which is best not only because of this issue, but because having set_property() maybe not set the property is confusing. --- src/Resource.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Resource.cpp b/src/Resource.cpp index 362e6b08..29a82772 100644 --- a/src/Resource.cpp +++ b/src/Resource.cpp @@ -53,6 +53,8 @@ Resource::add_property(const URI& uri, const Atom& value, Graph ctx) const Atom& Resource::set_property(const URI& uri, const Atom& value, Resource::Graph ctx) { + assert(uri != _uris.ingen_activity); // Always ephemeral + // Erase existing property in this context for (auto i = _properties.find(uri); (i != _properties.end()) && (i->first == uri);) { @@ -66,16 +68,10 @@ Resource::set_property(const URI& uri, const Atom& value, Resource::Graph ctx) i = next; } - if (uri != _uris.ingen_activity) { - // Insert new property - const Atom& v = _properties.emplace(uri, Property(value, ctx))->second; - on_property(uri, v); - return v; - } - - // Announce ephemeral activity, but do not store - on_property(uri, value); - return value; + // Insert new property + const Atom& v = _properties.emplace(uri, Property(value, ctx))->second; + on_property(uri, v); + return v; } const Atom& -- cgit v1.2.1