From 8ba8b353ca1bc838428fa0637be11d131ca637c7 Mon Sep 17 00:00:00 2001 From: Vova Sharaienko Date: Sat, 11 Feb 2023 02:06:37 +0000 Subject: [PATCH] [TeX] Improved readability for Histogram metric APIs Bug: 268161449 Test: atest expresslog_test Change-Id: Idd83ca6ec47288ca6ef7ecce333ceb3c88dd761a --- libstats/expresslog/Histogram.cpp | 7 ++++--- libstats/expresslog/include/Histogram.h | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libstats/expresslog/Histogram.cpp b/libstats/expresslog/Histogram.cpp index c90282d57..cb29a00a9 100644 --- a/libstats/expresslog/Histogram.cpp +++ b/libstats/expresslog/Histogram.cpp @@ -26,8 +26,8 @@ namespace android { namespace expresslog { -Histogram::UniformOptions* Histogram::UniformOptions::create(int binCount, float minValue, - float exclusiveMaxValue) { +std::shared_ptr Histogram::UniformOptions::create( + int binCount, float minValue, float exclusiveMaxValue) { if (binCount < 1) { ALOGE("Bin count should be positive number"); return nullptr; @@ -38,7 +38,8 @@ Histogram::UniformOptions* Histogram::UniformOptions::create(int binCount, float return nullptr; } - return new UniformOptions(binCount, minValue, exclusiveMaxValue); + return std::shared_ptr( + new UniformOptions(binCount, minValue, exclusiveMaxValue)); } Histogram::UniformOptions::UniformOptions(int binCount, float minValue, float exclusiveMaxValue) diff --git a/libstats/expresslog/include/Histogram.h b/libstats/expresslog/include/Histogram.h index aba278626..8fdc1b684 100644 --- a/libstats/expresslog/include/Histogram.h +++ b/libstats/expresslog/include/Histogram.h @@ -46,10 +46,9 @@ public: /** Used by Histogram to map data sample to corresponding bin for uniform bins */ class UniformOptions : public BinOptions { - UniformOptions(int binCount, float minValue, float exclusiveMaxValue); - public: - static UniformOptions* create(int binCount, float minValue, float exclusiveMaxValue); + static std::shared_ptr create(int binCount, float minValue, + float exclusiveMaxValue); int getBinsCount() const override { return mBinCount; @@ -58,6 +57,8 @@ public: int getBinForSample(float sample) const override; private: + UniformOptions(int binCount, float minValue, float exclusiveMaxValue); + const int mBinCount; const float mMinValue; const float mExclusiveMaxValue;