summaryrefslogtreecommitdiff
path: root/bson
diff options
context:
space:
mode:
authordwight <dwight@10gen.com>2011-07-15 14:14:08 -0400
committerdwight <dwight@10gen.com>2011-08-02 02:36:36 -0400
commit81fece68e9b0f1723b9c5d2e468fd2e43794022d (patch)
tree5f0dbfd3421d63ca8108f7e4e832c6437614be6d /bson
parentb1a62743d1ab7f1986bbe7faf36640fc16236b15 (diff)
downloadmongo-81fece68e9b0f1723b9c5d2e468fd2e43794022d.tar.gz
prefetch type stuff
Diffstat (limited to 'bson')
-rw-r--r--bson/bson-inl.h2
-rw-r--r--bson/bsonobjiterator.h2
-rw-r--r--bson/inline_decls.h17
3 files changed, 16 insertions, 5 deletions
diff --git a/bson/bson-inl.h b/bson/bson-inl.h
index 54431549852..0a0601cf08a 100644
--- a/bson/bson-inl.h
+++ b/bson/bson-inl.h
@@ -172,7 +172,7 @@ dodouble:
}
inline BSONObj BSONElement::embeddedObjectUserCheck() const {
- if ( isABSONObj() )
+ MONGOIF ( isABSONObj() )
return BSONObj(value());
stringstream ss;
ss << "invalid parameter: expected an object (" << fieldName() << ")";
diff --git a/bson/bsonobjiterator.h b/bson/bsonobjiterator.h
index 0d2344e002e..4a8b2751abc 100644
--- a/bson/bsonobjiterator.h
+++ b/bson/bsonobjiterator.h
@@ -37,7 +37,7 @@ namespace mongo {
*/
BSONObjIterator(const BSONObj& jso) {
int sz = jso.objsize();
- if ( sz == 0 ) {
+ MONGO_IF ( sz == 0 ) {
_pos = _theend = 0;
return;
}
diff --git a/bson/inline_decls.h b/bson/inline_decls.h
index 433a67010cb..af877a997a7 100644
--- a/bson/inline_decls.h
+++ b/bson/inline_decls.h
@@ -31,6 +31,7 @@
#endif
+namespace mongo {
/* Note: do not clutter code with these -- ONLY use in hot spots / significant loops. */
@@ -42,13 +43,23 @@
// branch prediction. indicate we expect to not enter the if statement body
# define MONGO_IF(x) if( (x) )
-// prefetch data from memory
-# define MONGOPREFETCH(x) { /*just check we compile:*/ assert(sizeof(*x)); }
+# if defined(_WIN32)
+ // prefetch data from memory
+ inline void prefetch(const void *p) {
+ _mm_prefetch((char *) p, _MM_HINT_T0);
+ }
+#else
+ inline void prefetch(void *p) { }
+#endif
#else
# define MONGOIF(x) if( __builtin_expect((x), 1) )
# define MONGO_IF(x) if( __builtin_expect((x), 0) )
-# define MONGOPREFETCH(x) { /*just check we compile:*/ assert(sizeof(*x)); }
+
+ inline void prefetch(void *p) {
+ }
#endif
+
+}