From 16c8199bfee0e9e27acef98700fd516451787ceb Mon Sep 17 00:00:00 2001 From: Arne Juul Date: Thu, 4 Oct 2018 11:35:34 +0000 Subject: use repo for descriptions --- metrics/src/vespa/metrics/metric.cpp | 15 +++++---------- metrics/src/vespa/metrics/metric.h | 8 +++++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/metrics/src/vespa/metrics/metric.cpp b/metrics/src/vespa/metrics/metric.cpp index 30d063dac1f..355957d11da 100644 --- a/metrics/src/vespa/metrics/metric.cpp +++ b/metrics/src/vespa/metrics/metric.cpp @@ -66,7 +66,7 @@ Metric::Metric(const String& name, MetricSet* owner) : _name(Repo::metricId(name)), _mangledName(_name), - _description(description), + _description(Repo::descriptionId(description)), _tags(legacyTagStringToKeyedTags(tags)), _owner(nullptr) // Set later by registry { @@ -81,7 +81,7 @@ Metric::Metric(const String& name, MetricSet* owner) : _name(Repo::metricId(name)), _mangledName(_name), - _description(description), + _description(Repo::descriptionId(description)), _tags(std::move(dimensions)), _owner(nullptr) { @@ -222,8 +222,7 @@ Metric::addMemoryUsage(MemoryConsumption& mc) const { ++mc._metricCount; mc._metricName += mc.getStringMemoryUsage(getName(), mc._metricNameUnique); - mc._metricDescription += mc.getStringMemoryUsage( - _description, mc._metricDescriptionUnique); + mc._metricDescription += mc.getStringMemoryUsage(getDescription(), mc._metricDescriptionUnique); mc._metricTagCount += _tags.size(); // XXX figure out what we actually want to report from tags here... // XXX we don't care about unique strings since they don't matter anymore. @@ -232,13 +231,9 @@ Metric::addMemoryUsage(MemoryConsumption& mc) const } void -Metric::updateNames(NameHash& hash) const +Metric::updateNames(NameHash&) const { - Metric& m(const_cast(*this)); - hash.updateName(m._description); - // Tags use vespalib::string which isn't refcounted under the hood and - // use small string optimizations, meaning the implicit ref sharing hack - // won't work for them anyway. + // not relevant anymore } void diff --git a/metrics/src/vespa/metrics/metric.h b/metrics/src/vespa/metrics/metric.h index a272c54a10f..c1adc15c28d 100644 --- a/metrics/src/vespa/metrics/metric.h +++ b/metrics/src/vespa/metrics/metric.h @@ -131,7 +131,7 @@ public: } vespalib::string getPath() const; std::vector getPathVector() const; - const String& getDescription() const { return _description; } + const vespalib::string& getDescription() const { return Repo::description(_description); } const Tags& getTags() const { return _tags; } /** Return whether there exists a tag with a key equal to 'tag' */ bool hasTag(const String& tag) const; @@ -223,7 +223,9 @@ public: } /** Used by sum metric to alter description of cloned metric for sum. */ - void setDescription(const String& d) { _description = d; } + void setDescription(const vespalib::string& d) { + _description = Repo::descriptionId(d); + } /** Used by sum metric to alter tag of cloned metric for sum. */ void setTags(Tags tags) { _tags = std::move(tags); @@ -296,7 +298,7 @@ private: protected: MetricNameId _name; MetricNameId _mangledName; - String _description; + DescriptionId _description; std::vector _tags; MetricSet* _owner; -- cgit v1.2.3