Commit 3f04c1b4 by Paolo Carlini

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
parent b1c6d018
...@@ -56,8 +56,8 @@ namespace __gnu_profile ...@@ -56,8 +56,8 @@ namespace __gnu_profile
_M_accesses(__o._M_accesses), _M_hops(__o._M_hops) { } _M_accesses(__o._M_accesses), _M_hops(__o._M_hops) { }
__hashfunc_info(__stack_t __stack) __hashfunc_info(__stack_t __stack)
: __object_info_base(__stack), : __object_info_base(__stack), _M_longest_chain(0),
_M_longest_chain(0), _M_accesses(0), _M_hops(0) { } _M_accesses(0), _M_hops(0) { }
virtual ~__hashfunc_info() { } virtual ~__hashfunc_info() { }
......
...@@ -190,8 +190,13 @@ namespace __gnu_profile ...@@ -190,8 +190,13 @@ namespace __gnu_profile
class __trace_base class __trace_base
{ {
public: public:
__trace_base(); // Do not pick the initial size too large, as we don't know which
virtual ~__trace_base() {} // 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); void __add_object(__object_t object, __object_info __info);
__object_info* __get_object_info(__object_t __object); __object_info* __get_object_info(__object_t __object);
...@@ -229,18 +234,6 @@ namespace __gnu_profile ...@@ -229,18 +234,6 @@ namespace __gnu_profile
} }
template<typename __object_info, typename __stack_info> 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 void
__trace_base<__object_info, __stack_info>:: __trace_base<__object_info, __stack_info>::
__add_object(__object_t __object, __object_info __info) __add_object(__object_t __object, __object_info __info)
...@@ -326,10 +319,8 @@ namespace __gnu_profile ...@@ -326,10 +319,8 @@ namespace __gnu_profile
__trace_base<__object_info, __stack_info>:: __trace_base<__object_info, __stack_info>::
__write(FILE* __f) __write(FILE* __f)
{ {
typename __stack_table_t::iterator __it; for (typename __stack_table_t::iterator __it
= __stack_table.begin(); __it != __stack_table.end(); ++__it)
for (__it = __stack_table.begin(); __it != __stack_table.end(); ++__it)
{
if (__it->second.__is_valid()) if (__it->second.__is_valid())
{ {
std::fprintf(__f, __id); std::fprintf(__f, __id);
...@@ -339,7 +330,6 @@ namespace __gnu_profile ...@@ -339,7 +330,6 @@ namespace __gnu_profile
__it->second.__write(__f); __it->second.__write(__f);
} }
} }
}
inline std::size_t inline std::size_t
__env_to_size_t(const char* __env_var, std::size_t __default_value) __env_to_size_t(const char* __env_var, std::size_t __default_value)
...@@ -414,18 +404,17 @@ namespace __gnu_profile ...@@ -414,18 +404,17 @@ namespace __gnu_profile
*(__file_name + __root_len) = '.'; *(__file_name + __root_len) = '.';
__builtin_memcpy(__file_name + __root_len + 1, __builtin_memcpy(__file_name + __root_len + 1,
__extension, __ext_len + 1); __extension, __ext_len + 1);
FILE* __out_file = std::fopen(__file_name, "w"); FILE* __out_file = std::fopen(__file_name, "w");
if (__out_file) if (!__out_file)
{
delete[] __file_name;
return __out_file;
}
else
{ {
std::fprintf(stderr, "Could not open trace file '%s'.\n", std::fprintf(stderr, "Could not open trace file '%s'.\n",
__file_name); __file_name);
std::abort(); std::abort();
} }
delete[] __file_name;
return __out_file;
} }
struct __warn struct __warn
...@@ -544,7 +533,9 @@ namespace __gnu_profile ...@@ -544,7 +533,9 @@ namespace __gnu_profile
struct __cost_factor_writer struct __cost_factor_writer
{ {
FILE* __file; FILE* __file;
__cost_factor_writer(FILE* __f) : __file(__f) { }
__cost_factor_writer(FILE* __f)
: __file(__f) { }
void void
operator() (const __cost_factor* __factor) operator() (const __cost_factor* __factor)
...@@ -565,7 +556,7 @@ namespace __gnu_profile ...@@ -565,7 +556,7 @@ namespace __gnu_profile
struct __cost_factor_setter struct __cost_factor_setter
{ {
void void
operator() (__cost_factor* __factor) operator()(__cost_factor* __factor)
{ {
// Look it up in the process environment first. // Look it up in the process environment first.
const char* __env_value = std::getenv(__factor->__env_var); const char* __env_value = std::getenv(__factor->__env_var);
...@@ -663,7 +654,7 @@ namespace __gnu_profile ...@@ -663,7 +654,7 @@ namespace __gnu_profile
* The common path is inlined fully. * The common path is inlined fully.
*/ */
inline bool inline bool
__profcxx_init(void) __profcxx_init()
{ {
if (__is_invalid()) if (__is_invalid())
__profcxx_init_unconditional(); __profcxx_init_unconditional();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment