From 5bfd0a44f68943ec285d9453e4ed7097b668c3de Mon Sep 17 00:00:00 2001 From: "asvitkine@chromium.org" Date: Sat, 15 Feb 2014 03:11:45 +0000 Subject: Make code generated for histogram macros more compact. In builds where DCHECKs are compiled in (e.g. developer builds and Chrome Canaries), the DCHECK_EQ() in the histogram macro was expanding to a lot of generated machine code. This CL moves that DCHECK() to a function instead, so that the code is not duplicated in every call site. The function call is wrapped behind a DCHECK_IS_ON() conditional, so that it will still be omitted if DCHECKs are not compiled into the build. Makes my Chromium release build smaller by over 1MB, measuring size of Chromium Framework. Before size: 146547380 After size: 145400692 BUG=343946 TEST=No functional changes. Review URL: https://codereview.chromium.org/167343002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251486 0039d316-1c4b-4281-b951-d872f2087c98 --- base/metrics/histogram.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'base/metrics/histogram.h') diff --git a/base/metrics/histogram.h b/base/metrics/histogram.h index 7a6c688..02f3ac4 100644 --- a/base/metrics/histogram.h +++ b/base/metrics/histogram.h @@ -155,8 +155,8 @@ class Lock; base::subtle::Release_Store(&atomic_histogram_pointer, \ reinterpret_cast(histogram_pointer)); \ } \ - DCHECK_EQ(histogram_pointer->histogram_name(), \ - std::string(constant_histogram_name)); \ + if (DCHECK_IS_ON()) \ + histogram_pointer->CheckName(constant_histogram_name); \ histogram_pointer->histogram_add_method_invocation; \ } while (0) -- cgit v1.1