Skip to content

Commit

Permalink
use StringData instead of string for memconcept to avoid malloc
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Oct 24, 2012
1 parent 76c04a7 commit 069deac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/mongo/db/memconcept.cpp
Expand Up @@ -102,13 +102,13 @@ namespace mongo {

#if 0 && defined(_DEBUG)
bool d = false;
void is(void *p, concept c, const std::string& description, unsigned len) {
DDD( log() << "is " << p << ' ' << c.toString() << ' ' << description << ' ' << len << endl; )
void is(void *p, concept c, const StringData& description, unsigned len) {
DDD( log() << "is " << p << ' ' << c.toString() << ' ' << description.data() << ' ' << len << endl; )
C &node = map.find(p);
node.p = p;
node.c = c;
node.len = len;
strncpy(node.desc, description.c_str(), 15);
strncpy(node.desc, description.data(), 15);
}

void invalidate(void *p, unsigned len) {
Expand Down
10 changes: 6 additions & 4 deletions src/mongo/db/memconcept.h
@@ -1,5 +1,3 @@
#pragma once

/**
* Copyright (C) 2012 10gen Inc.
*
Expand All @@ -22,6 +20,10 @@
be for _DEBUG builds. Experimental we'll see how useful.
*/

#pragma once

#include "mongo/base/string_data.h"

namespace mongo {
namespace memconcept {

Expand Down Expand Up @@ -54,12 +56,12 @@ namespace mongo {

/** note you can be more than one thing; a datafile header is also the starting pointer
for a file */
void is(void *p, concept c, const std::string desc = "", unsigned len=0);
void is(void *p, concept c, const StringData& desc = StringData( "", 0 ), unsigned len=0);

#if 1
//#if !defined(_DEBUG)
inline void invalidate(void *p, unsigned len) { }
inline void is(void *p, concept c, const std::string, unsigned) { }
inline void is(void *p, concept c, const StringData& desc, unsigned) { }
#endif

}
Expand Down

0 comments on commit 069deac

Please sign in to comment.