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

Unified Diff: base/compiler_specific.h

Issue 160673002: Use branch prediction hints to make trace events cheaper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't redefined macros. Created 6 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/debug/trace_event.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/compiler_specific.h
diff --git a/base/compiler_specific.h b/base/compiler_specific.h
index 2ba34da1cc4bbfef27264de7b34ece19628ef1b0..cbb60a0d6783e4d7f72f5aae449b3460eb6a3005 100644
--- a/base/compiler_specific.h
+++ b/base/compiler_specific.h
@@ -218,4 +218,22 @@
#endif // defined(OS_WIN)
#endif // !defined(CDECL)
+// Macro for hinting that an expression is likely to be true.
+#if !defined(LIKELY)
+#if defined(COMPILER_GCC)
+#define LIKELY(x) __builtin_expect(!!(x), 1)
+#else
+#define LIKELY(x) (x)
+#endif // defined(COMPILER_GCC)
+#endif // !defined(LIKELY)
+
+// Macro for hinting that an expression is likely to be false.
+#if !defined(UNLIKELY)
+#if defined(COMPILER_GCC)
+#define UNLIKELY(x) __builtin_expect(!!(x), 0)
+#else
+#define UNLIKELY(x) (x)
+#endif // defined(COMPILER_GCC)
+#endif // !defined(UNLIKELY)
+
#endif // BASE_COMPILER_SPECIFIC_H_
« no previous file with comments | « no previous file | base/debug/trace_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698