From 546499713651809f026e118f81b9c52f01c895f6 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 26 Aug 2009 17:35:54 -0700 Subject: Remove unnecessary static members When a static class member is only used by a single method, it's more concise to use a static local variable instead. * staptree.cxx (probe::probe): Make last_probeidx a static local. * tapset-perfmon.cxx (perfmon_derived_probe::perfmon_derived_probe): Make probes_allocated a static local. --- staptree.cxx | 2 +- staptree.h | 3 --- tapset-perfmon.cxx | 10 ++-------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/staptree.cxx b/staptree.cxx index aa37b754..b4975017 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -97,10 +97,10 @@ probe_point::probe_point (): } -unsigned probe::last_probeidx = 0; probe::probe (): body (0), tok (0) { + static unsigned last_probeidx = 0; this->name = string ("probe_") + lex_cast(last_probeidx ++); } diff --git a/staptree.h b/staptree.h index f1d43403..de148ce0 100644 --- a/staptree.h +++ b/staptree.h @@ -660,9 +660,6 @@ struct probe virtual probe* basest () { return this; } virtual ~probe() {} bool privileged; -private: - static unsigned last_probeidx; -public: std::string name; }; diff --git a/tapset-perfmon.cxx b/tapset-perfmon.cxx index 86806d61..827e88ca 100644 --- a/tapset-perfmon.cxx +++ b/tapset-perfmon.cxx @@ -96,10 +96,6 @@ enum perfmon_mode struct perfmon_derived_probe: public derived_probe { -protected: - static unsigned probes_allocated; - -public: systemtap_session & sess; string event; perfmon_mode mode; @@ -142,17 +138,15 @@ struct perfmon_builder: public derived_probe_builder }; -unsigned perfmon_derived_probe::probes_allocated; - perfmon_derived_probe::perfmon_derived_probe (probe* p, probe_point* l, systemtap_session &s, string e, perfmon_mode m) : derived_probe (p, l), sess(s), event(e), mode(m) { - ++probes_allocated; + static unsigned probes_allocated = 0; // Now expand the local variables in the probe body - perfmon_var_expanding_visitor v (sess, probes_allocated-1); + perfmon_var_expanding_visitor v (sess, probes_allocated++); v.replace (this->body); if (sess.verbose > 1) -- cgit