carnold 2004/08/23 14:07:33
Modified: include/log4cxx logger.h
Log:
PR: LOGCXX-13
Submitted by: [EMAIL PROTECTED]
Revision Changes Path
1.23 +22 -1 logging-log4cxx/include/log4cxx/logger.h
Index: logger.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/logger.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- logger.h 13 May 2004 21:14:38 -0000 1.22
+++ logger.h 23 Aug 2004 21:07:33 -0000 1.23
@@ -542,6 +542,27 @@
@{
*/
+#if !defined(LOG4CXX_UNLIKELY)
+#if __GNUC__ >= 3
+/**
+Provides optimization hint to the compiler
+to optimize for the expression being false.
[EMAIL PROTECTED] expr boolean expression.
[EMAIL PROTECTED] value of expression.
+*/
+#define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0)
+#else
+/**
+Provides optimization hint to the compiler
+to optimize for the expression being false.
[EMAIL PROTECTED] expr boolean expression.
[EMAIL PROTECTED] value of expression.
+**/
+#define LOG4CXX_UNLIKELY(expr) expr
+#endif
+#endif
+
+
/**
Logs a message to a specified logger with a specified level.
@@ -562,7 +583,7 @@
@param message the message string to log.
*/
#define LOG4CXX_DEBUG(logger, message) { \
- if (logger->isDebugEnabled()) {\
+ if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {\
::log4cxx::StringBuffer oss; \
oss << message; \
logger->forcedLog(::log4cxx::Level::DEBUG, oss.str(), __FILE__,
__LINE__); }}