diff options
author | Paolo Carlini <paolo@gcc.gnu.org> | 2010-06-24 18:52:31 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2010-06-24 18:52:31 +0000 |
commit | 3f04c1b4bd0df2210c46120178f6b84bc242ca2a (patch) | |
tree | 33039b34e3ff8251ddba944593379157089bbaae /libstdc++-v3 | |
parent | b1c6d0185ae2978fee81aa96c256d3d6358a7adb (diff) | |
download | gcc-3f04c1b4bd0df2210c46120178f6b84bc242ca2a.zip gcc-3f04c1b4bd0df2210c46120178f6b84bc242ca2a.tar.gz gcc-3f04c1b4bd0df2210c46120178f6b84bc242ca2a.tar.bz2 |
profiler_trace.h (__trace_base<>:: __trace_base()): Move inline, simplify; formatting tweaks.
2010-06-24 Paolo Carlini <paolo.carlini@oracle.com>
* include/profile/impl/profiler_trace.h (__trace_base<>::
__trace_base()): Move inline, simplify; formatting tweaks.
* include/profile/impl/profiler_hash_func.h: Formatting tweaks.
From-SVN: r161333
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/include/profile/impl/profiler_hash_func.h | 14 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/impl/profiler_trace.h | 65 |
2 files changed, 35 insertions, 44 deletions
diff --git a/libstdc++-v3/include/profile/impl/profiler_hash_func.h b/libstdc++-v3/include/profile/impl/profiler_hash_func.h index b02f453..3e01760 100644 --- a/libstdc++-v3/include/profile/impl/profiler_hash_func.h +++ b/libstdc++-v3/include/profile/impl/profiler_hash_func.h @@ -50,15 +50,15 @@ namespace __gnu_profile public: __hashfunc_info() : _M_longest_chain(0), _M_accesses(0), _M_hops(0) { } - + __hashfunc_info(const __hashfunc_info& __o) - : __object_info_base(__o), _M_longest_chain(__o._M_longest_chain), - _M_accesses(__o._M_accesses), _M_hops(__o._M_hops) { } - + : __object_info_base(__o), _M_longest_chain(__o._M_longest_chain), + _M_accesses(__o._M_accesses), _M_hops(__o._M_hops) { } + __hashfunc_info(__stack_t __stack) - : __object_info_base(__stack), - _M_longest_chain(0), _M_accesses(0), _M_hops(0) { } - + : __object_info_base(__stack), _M_longest_chain(0), + _M_accesses(0), _M_hops(0) { } + virtual ~__hashfunc_info() { } void diff --git a/libstdc++-v3/include/profile/impl/profiler_trace.h b/libstdc++-v3/include/profile/impl/profiler_trace.h index ce1964a..0c0aec8f 100644 --- a/libstdc++-v3/include/profile/impl/profiler_trace.h +++ b/libstdc++-v3/include/profile/impl/profiler_trace.h @@ -190,8 +190,13 @@ namespace __gnu_profile class __trace_base { public: - __trace_base(); - virtual ~__trace_base() {} + // Do not pick the initial size too large, as we don't know which + // diagnostics are more active. + __trace_base() + : __object_table(10000), __stack_table(10000), + __stack_table_byte_size(0), __id(0) { } + + virtual ~__trace_base() { } void __add_object(__object_t object, __object_info __info); __object_info* __get_object_info(__object_t __object); @@ -229,18 +234,6 @@ namespace __gnu_profile } template<typename __object_info, typename __stack_info> - __trace_base<__object_info, __stack_info>:: - __trace_base() - { - // Do not pick the initial size too large, as we don't know which - // diagnostics are more active. - __object_table.rehash(10000); - __stack_table.rehash(10000); - __stack_table_byte_size = 0; - __id = 0; - } - - template<typename __object_info, typename __stack_info> void __trace_base<__object_info, __stack_info>:: __add_object(__object_t __object, __object_info __info) @@ -326,19 +319,16 @@ namespace __gnu_profile __trace_base<__object_info, __stack_info>:: __write(FILE* __f) { - typename __stack_table_t::iterator __it; - - for (__it = __stack_table.begin(); __it != __stack_table.end(); ++__it) - { - if (__it->second.__is_valid()) - { - std::fprintf(__f, __id); - std::fprintf(__f, "|"); - __gnu_profile::__write(__f, __it->first); - std::fprintf(__f, "|"); - __it->second.__write(__f); - } - } + for (typename __stack_table_t::iterator __it + = __stack_table.begin(); __it != __stack_table.end(); ++__it) + if (__it->second.__is_valid()) + { + std::fprintf(__f, __id); + std::fprintf(__f, "|"); + __gnu_profile::__write(__f, __it->first); + std::fprintf(__f, "|"); + __it->second.__write(__f); + } } inline std::size_t @@ -414,18 +404,17 @@ namespace __gnu_profile *(__file_name + __root_len) = '.'; __builtin_memcpy(__file_name + __root_len + 1, __extension, __ext_len + 1); + FILE* __out_file = std::fopen(__file_name, "w"); - if (__out_file) - { - delete[] __file_name; - return __out_file; - } - else + if (!__out_file) { std::fprintf(stderr, "Could not open trace file '%s'.\n", __file_name); std::abort(); } + + delete[] __file_name; + return __out_file; } struct __warn @@ -544,8 +533,10 @@ namespace __gnu_profile struct __cost_factor_writer { FILE* __file; - __cost_factor_writer(FILE* __f) : __file(__f) { } - + + __cost_factor_writer(FILE* __f) + : __file(__f) { } + void operator() (const __cost_factor* __factor) { std::fprintf(__file, "%s = %f\n", __factor->__env_var, @@ -565,7 +556,7 @@ namespace __gnu_profile struct __cost_factor_setter { void - operator() (__cost_factor* __factor) + operator()(__cost_factor* __factor) { // Look it up in the process environment first. const char* __env_value = std::getenv(__factor->__env_var); @@ -663,7 +654,7 @@ namespace __gnu_profile * The common path is inlined fully. */ inline bool - __profcxx_init(void) + __profcxx_init() { if (__is_invalid()) __profcxx_init_unconditional(); |