base: Make read-only functions const in ScalarBase
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Wed, 19 Feb 2020 08:27:17 +0000 (09:27 +0100)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Fri, 5 Feb 2021 14:10:31 +0000 (14:10 +0000)
These functions do not need to modify their storage's contents.

ScalarBase's non-const value() has been removed.

Change-Id: I4dd3899a29a741a7d8cd199ccd254b346d86ae07
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27084
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>

src/base/statistics.hh

index 1c3d53df633e0aa18fa30cc7e8eb99fcf14f3800..b1f27c72617dd16d8b620178f7af894cec7e0332 100644 (file)
@@ -522,13 +522,6 @@ class ScalarBase : public DataWrap<Derived, ScalarInfoProxy>
         this->setInit();
     }
 
-  public:
-    /**
-     * Return the current value of this stat as its base type.
-     * @return The current value.
-     */
-    Counter value() const { return data()->value(); }
-
   public:
     ScalarBase(Group *parent = nullptr, const char *name = nullptr,
                const char *desc = nullptr)
@@ -585,13 +578,17 @@ class ScalarBase : public DataWrap<Derived, ScalarInfoProxy>
      */
     size_type size() const { return 1; }
 
-    Counter value() { return data()->value(); }
+    /**
+     * Return the current value of this stat as its base type.
+     * @return The current value.
+     */
+    Counter value() const { return data()->value(); }
 
-    Result result() { return data()->result(); }
+    Result result() const { return data()->result(); }
 
-    Result total() { return result(); }
+    Result total() const { return result(); }
 
-    bool zero() { return result() == 0.0; }
+    bool zero() const { return result() == 0.0; }
 
     void reset() { data()->reset(this->info()); }
     void prepare() { data()->prepare(this->info()); }