From 4efaae056697c024920bfe387cf31d6ec37c749f Mon Sep 17 00:00:00 2001 From: dwight Date: Fri, 17 Dec 2010 07:59:45 -0500 Subject: dur optimizing seeting context to local database as that will be super common case --- db/dur.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'db/dur.cpp') diff --git a/db/dur.cpp b/db/dur.cpp index 906b4030272..278e9e8b993 100644 --- a/db/dur.cpp +++ b/db/dur.cpp @@ -194,6 +194,8 @@ namespace mongo { } #endif + RelativePath local = RelativePath::fromRelativePath("local"); + /** we will build an output buffer ourself and then use O_DIRECT we could be in read lock for this caller handles locking @@ -239,18 +241,21 @@ namespace mongo { mmf->willNeedRemap() = true; } i->w_ptr = ((char*)mmf->view_write()) + ofs; - if( mmf->relativePath() != lastFilePath ) { + JEntry e; + e.len = i->len; + assert( ofs <= 0x80000000 ); + e.ofs = (unsigned) ofs; + e.setFileNo( mmf->fileSuffixNo() ); + if( mmf->relativePath() == local ) { + e.setLocalDbContextBit(); + } + else if( mmf->relativePath() != lastFilePath ) { lastFilePath = mmf->relativePath(); //assert( !str::startsWith(lastFilePath, dbpath) ); // dbpath should be stripped this is a relative path JDbContext c; bb.appendStruct(c); bb.appendStr(lastFilePath.toString()); } - JEntry e; - e.len = i->len; - assert( ofs <= 0x80000000 ); - e.ofs = (unsigned) ofs; - e.fileNo = mmf->fileSuffixNo(); bb.appendStruct(e); bb.appendBuf(i->p, i->len); } -- cgit v1.2.1