Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: base/logging.h

Issue 2589943002: Wrap the conditional in CHECK with UNLIKELY since it is. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_LOGGING_H_ 5 #ifndef BASE_LOGGING_H_
6 #define BASE_LOGGING_H_ 6 #define BASE_LOGGING_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cassert> 10 #include <cassert>
11 #include <cstring> 11 #include <cstring>
12 #include <sstream> 12 #include <sstream>
13 #include <string> 13 #include <string>
14 #include <type_traits> 14 #include <type_traits>
15 #include <utility> 15 #include <utility>
16 16
17 #include "base/base_export.h" 17 #include "base/base_export.h"
18 #include "base/compiler_specific.h"
18 #include "base/debug/debugger.h" 19 #include "base/debug/debugger.h"
19 #include "base/macros.h" 20 #include "base/macros.h"
20 #include "base/template_util.h" 21 #include "base/template_util.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 23
23 // 24 //
24 // Optional message capabilities 25 // Optional message capabilities
25 // ----------------------------- 26 // -----------------------------
26 // Assertion failed messages and fatal errors are displayed in a dialog box 27 // Assertion failed messages and fatal errors are displayed in a dialog box
27 // before the application exits. However, running this UI creates a message 28 // before the application exits. However, running this UI creates a message
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 476
476 #if defined(OFFICIAL_BUILD) && defined(NDEBUG) 477 #if defined(OFFICIAL_BUILD) && defined(NDEBUG)
477 478
478 // Make all CHECK functions discard their log strings to reduce code bloat, and 479 // Make all CHECK functions discard their log strings to reduce code bloat, and
479 // improve performance, for official release builds. 480 // improve performance, for official release builds.
480 // 481 //
481 // This is not calling BreakDebugger since this is called frequently, and 482 // This is not calling BreakDebugger since this is called frequently, and
482 // calling an out-of-line function instead of a noreturn inline macro prevents 483 // calling an out-of-line function instead of a noreturn inline macro prevents
483 // compiler optimizations. 484 // compiler optimizations.
484 #define CHECK(condition) \ 485 #define CHECK(condition) \
485 !(condition) ? IMMEDIATE_CRASH() : EAT_STREAM_PARAMETERS 486 UNLIKELY(!(condition)) ? IMMEDIATE_CRASH() : EAT_STREAM_PARAMETERS
486 487
487 #define PCHECK(condition) CHECK(condition) 488 #define PCHECK(condition) CHECK(condition)
488 489
489 #define CHECK_OP(name, op, val1, val2) CHECK((val1) op (val2)) 490 #define CHECK_OP(name, op, val1, val2) CHECK((val1) op (val2))
490 491
491 #else // !(OFFICIAL_BUILD && NDEBUG) 492 #else // !(OFFICIAL_BUILD && NDEBUG)
492 493
493 #if defined(_PREFAST_) && defined(OS_WIN) 494 #if defined(_PREFAST_) && defined(OS_WIN)
494 // Use __analysis_assume to tell the VC++ static analysis engine that 495 // Use __analysis_assume to tell the VC++ static analysis engine that
495 // assert conditions are true, to suppress warnings. The LAZY_STREAM 496 // assert conditions are true, to suppress warnings. The LAZY_STREAM
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 #elif NOTIMPLEMENTED_POLICY == 5 1018 #elif NOTIMPLEMENTED_POLICY == 5
1018 #define NOTIMPLEMENTED() do {\ 1019 #define NOTIMPLEMENTED() do {\
1019 static bool logged_once = false;\ 1020 static bool logged_once = false;\
1020 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 1021 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
1021 logged_once = true;\ 1022 logged_once = true;\
1022 } while(0);\ 1023 } while(0);\
1023 EAT_STREAM_PARAMETERS 1024 EAT_STREAM_PARAMETERS
1024 #endif 1025 #endif
1025 1026
1026 #endif // BASE_LOGGING_H_ 1027 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698