0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

slightly safer record usage of compiler hack

This commit is contained in:
Eliot Horowitz 2011-07-15 17:58:29 -04:00
parent 0ed5ef7b06
commit d71afc52d7

View File

@ -180,14 +180,17 @@ namespace mongo {
bool Record::MemoryTrackingEnabled = true;
int __record_touch_dummy = 1; // this is used to make sure the compiler doesn't get too smart on us
volatile int __record_touch_dummy = 1; // this is used to make sure the compiler doesn't get too smart on us
void Record::touch( bool entireRecrd ) {
if ( lengthWithHeaders > HeaderSize ) { // this also makes sure lengthWithHeaders is in memory
char * addr = data;
char * end = data + netLength();
for ( ; addr <= end ; addr += 2048 )
for ( ; addr <= end ; addr += 2048 ) {
__record_touch_dummy += addr[0];
if ( ! entireRecrd )
break;
}
}
}