diff options
author | Dwight <dwight@10gen.com> | 2010-08-03 11:19:27 -0400 |
---|---|---|
committer | Dwight <dwight@10gen.com> | 2010-08-03 11:19:27 -0400 |
commit | fd10e8b430ee42cda42c5706440c6dffe2078a1f (patch) | |
tree | 250f1f9cdc66339be99eb3cca92c7352482c77e9 | |
parent | a67fc0b576096f363420ff2ac236512d9239da23 (diff) | |
parent | c8ae18d4b4118443bd084be51d75669113eb79dc (diff) | |
download | mongo-fd10e8b430ee42cda42c5706440c6dffe2078a1f.tar.gz |
Merge branch 'master' of github.com:mongodb/mongo
-rw-r--r-- | bson/bson.cpp | 34 | ||||
-rw-r--r-- | bson/bsondemo/bsondemo.vcxproj | 5 | ||||
-rw-r--r-- | bson/bsondemo/bsondemo.vcxproj.filters | 5 | ||||
-rw-r--r-- | bson/inline_decls.h | 33 | ||||
-rw-r--r-- | bson/util/builder.h | 14 | ||||
-rw-r--r-- | db/jsobj.cpp | 2 |
6 files changed, 50 insertions, 43 deletions
diff --git a/bson/bson.cpp b/bson/bson.cpp deleted file mode 100644 index 944bae053e3..00000000000 --- a/bson/bson.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* bson.cpp
-*/
-
-#include "util/builder.h"
-
-namespace mongo {
-
- /* there is an inline-only subset of the bson library; however, it is best if grow_reallocate function is not inlined to
- improve performance. Thus grow_reallocate is here. The idea is that this file is a very MINIMAL set of code
- for use when using the C++ BSON library and that it does not pull in a lot of other code prerequisites.
-
- bsondemo.cpp will compile and link with itself and this file only (no libs) -- that's the idea.
-
- jsobj.cpp currently #include's this file, so don't include both bson.cpp and jsobj.cpp in your project
- at the same time -- just use jsobj.cpp if you need all that...
-
- This is interim and will evolve, but gets bsondemo.cpp compiling again sans libraries.
- */
-
- /* BufBuilder --------------------------------------------------------*/ - - void BufBuilder::grow_reallocate() { - int a = size * 2; - if ( a == 0 ) - a = 512; - if ( l > a ) - a = l + 16 * 1024; - if( a > 64 * 1024 * 1024 ) - msgasserted(10000, "BufBuilder grow() > 64MB"); - data = (char *) realloc(data, a); - size= a; - } - -} diff --git a/bson/bsondemo/bsondemo.vcxproj b/bson/bsondemo/bsondemo.vcxproj index 41cf8f228f3..bb82a505325 100644 --- a/bson/bsondemo/bsondemo.vcxproj +++ b/bson/bsondemo/bsondemo.vcxproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@@ -170,7 +170,6 @@ </Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\bson.cpp" />
<ClCompile Include="bsondemo.cpp" />
</ItemGroup>
<ItemGroup>
@@ -191,4 +190,4 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
\ No newline at end of file +</Project>
diff --git a/bson/bsondemo/bsondemo.vcxproj.filters b/bson/bsondemo/bsondemo.vcxproj.filters index 6642f379433..35f14d5193b 100644 --- a/bson/bsondemo/bsondemo.vcxproj.filters +++ b/bson/bsondemo/bsondemo.vcxproj.filters @@ -1,8 +1,7 @@ -<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="bsondemo.cpp" />
- <ClCompile Include="..\bson.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\ordering.h">
@@ -50,4 +49,4 @@ <UniqueIdentifier>{ea599740-3c6f-40dd-a121-e825d82ae4aa}</UniqueIdentifier>
</Filter>
</ItemGroup>
-</Project>
\ No newline at end of file +</Project>
diff --git a/bson/inline_decls.h b/bson/inline_decls.h new file mode 100644 index 00000000000..aab9810a9c3 --- /dev/null +++ b/bson/inline_decls.h @@ -0,0 +1,33 @@ +// inline.h + +/** +* Copyright (C) 2010 10gen Inc. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License, version 3, +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#pragma once + +#if defined(__GNUC__) + +#define NOINLINE_DECL __attribute__((noinline)) + +#elif defined(_MSC_VER) + +#define NOINLINE_DECL __declspec(noinline) + +#else + +#define NOINLINE_DECL + +#endif diff --git a/bson/util/builder.h b/bson/util/builder.h index ec1973b5d2c..75a1ad836c2 100644 --- a/bson/util/builder.h +++ b/bson/util/builder.h @@ -21,6 +21,8 @@ #include <string.h> #include <stdio.h> #include <boost/shared_ptr.hpp> + +#include "../inline_decls.h" #include "../stringdata.h" namespace mongo { @@ -130,7 +132,17 @@ namespace mongo { private: /* "slow" portion of 'grow()' */ - void grow_reallocate(); + void NOINLINE_DECL grow_reallocate(){ + int a = size * 2; + if ( a == 0 ) + a = 512; + if ( l > a ) + a = l + 16 * 1024; + if( a > 64 * 1024 * 1024 ) + msgasserted(10000, "BufBuilder grow() > 64MB"); + data = (char *) realloc(data, a); + size= a; + } char *data; int l; diff --git a/db/jsobj.cpp b/db/jsobj.cpp index feaa28d50c4..9f613c752c4 100644 --- a/db/jsobj.cpp +++ b/db/jsobj.cpp @@ -40,8 +40,6 @@ BOOST_STATIC_ASSERT( sizeof(double) == 8 ); BOOST_STATIC_ASSERT( sizeof(mongo::Date_t) == 8 ); BOOST_STATIC_ASSERT( sizeof(mongo::OID) == 12 ); -#include "../bson/bson.cpp" - namespace mongo { BSONElement nullElement; |