summaryrefslogtreecommitdiff
path: root/bson
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2011-08-02 18:50:04 -0400
committerMathias Stearn <mathias@10gen.com>2011-08-02 18:50:04 -0400
commite2778cdf78239e136eaa36680869608441fc9934 (patch)
tree0589c9a7f2da632d8844735faf3cca4ade9ff7f6 /bson
parenta83ddcd22c6d60f050cccc95a6c3231376292add (diff)
downloadmongo-e2778cdf78239e136eaa36680869608441fc9934.tar.gz
Use more common (and readable) names for branch prediction hints
Diffstat (limited to 'bson')
-rw-r--r--bson/bson-inl.h2
-rw-r--r--bson/bsonobjiterator.h2
-rw-r--r--bson/inline_decls.h12
3 files changed, 8 insertions, 8 deletions
diff --git a/bson/bson-inl.h b/bson/bson-inl.h
index 0a0601cf08a..b86d66784ed 100644
--- a/bson/bson-inl.h
+++ b/bson/bson-inl.h
@@ -172,7 +172,7 @@ dodouble:
}
inline BSONObj BSONElement::embeddedObjectUserCheck() const {
- MONGOIF ( isABSONObj() )
+ if ( MONGO_likely(isABSONObj()) )
return BSONObj(value());
stringstream ss;
ss << "invalid parameter: expected an object (" << fieldName() << ")";
diff --git a/bson/bsonobjiterator.h b/bson/bsonobjiterator.h
index 4a8b2751abc..39ae24d9b86 100644
--- a/bson/bsonobjiterator.h
+++ b/bson/bsonobjiterator.h
@@ -37,7 +37,7 @@ namespace mongo {
*/
BSONObjIterator(const BSONObj& jso) {
int sz = jso.objsize();
- MONGO_IF ( sz == 0 ) {
+ if ( MONGO_unlikely(sz == 0) ) {
_pos = _theend = 0;
return;
}
diff --git a/bson/inline_decls.h b/bson/inline_decls.h
index 067affaabd9..30da9b4560d 100644
--- a/bson/inline_decls.h
+++ b/bson/inline_decls.h
@@ -37,11 +37,11 @@ namespace mongo {
#if !defined(__GNUC__)
-// branch prediction. indicate we expect to enter the if statement body
-# define MONGOIF(x) if( (x) )
+// branch prediction. indicate we expect to be true
+# define MONGO_likely(x) ((bool)(x))
-// branch prediction. indicate we expect to not enter the if statement body
-# define MONGO_IF(x) if( (x) )
+// branch prediction. indicate we expect to be false
+# define MONGO_unlikely(x) ((bool)(x))
# if defined(_WIN32)
// prefetch data from memory
@@ -56,8 +56,8 @@ namespace mongo {
#else
-# define MONGOIF(x) if( __builtin_expect((x), 1) )
-# define MONGO_IF(x) if( __builtin_expect((x), 0) )
+# define MONGO_likely(x) ( __builtin_expect((bool)(x), 1) )
+# define MONGO_unlikely(x) ( __builtin_expect((bool)(x), 0) )
inline void prefetch(void *p) {
__builtin_prefetch(p);