summaryrefslogtreecommitdiff
path: root/bson
diff options
context:
space:
mode:
authorAlberto Lerner <alerner@10gen.com>2010-08-03 11:08:08 -0400
committerAlberto Lerner <alerner@10gen.com>2010-08-03 11:08:08 -0400
commitc8ae18d4b4118443bd084be51d75669113eb79dc (patch)
treebca57e1533a32573af0571b69ff32c5c485ea08f /bson
parent4cb2fac206b4d11b7f3f6cf734319488db872d52 (diff)
downloadmongo-c8ae18d4b4118443bd084be51d75669113eb79dc.tar.gz
change back header-only bson
Diffstat (limited to 'bson')
-rw-r--r--bson/bson.cpp34
-rw-r--r--bson/bsondemo/bsondemo.vcxproj5
-rw-r--r--bson/bsondemo/bsondemo.vcxproj.filters5
-rw-r--r--bson/inline_decls.h33
-rw-r--r--bson/util/builder.h14
5 files changed, 50 insertions, 41 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;