Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
c752b6aa
Commit
c752b6aa
authored
Jun 25, 2015
by
Milo Yip
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #365 from mloskot/patch-1
Add missing allocator to uses of AddMember
parents
a326314a
74b41c1a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
tutorial.md
doc/tutorial.md
+4
-2
No files found.
doc/tutorial.md
View file @
c752b6aa
...
...
@@ -292,12 +292,13 @@ The simple answer is performance. For fixed size JSON types (Number, True, False
For example, if normal
*copy*
semantics was used:
~~~
~~~~~~~cpp
Document d;
Value o(kObjectType);
{
Value contacts(kArrayType);
// adding elements to contacts array.
// ...
o.AddMember("contacts", contacts); // deep clone contacts (may be with lots of allocations)
o.AddMember("contacts", contacts
, d.GetAllocator()
); // deep clone contacts (may be with lots of allocations)
// destruct contacts.
}
~~~
~~~~~~~
...
...
@@ -313,11 +314,12 @@ To make RapidJSON simple and fast, we chose to use *move* semantics for assignme
So, with move semantics, the above example becomes:
~~~
~~~~~~~cpp
Document d;
Value o(kObjectType);
{
Value contacts(kArrayType);
// adding elements to contacts array.
o.AddMember("contacts", contacts); // just memcpy() of contacts itself to the value of new member (16 bytes)
o.AddMember("contacts", contacts
, d.GetAllocator()
); // just memcpy() of contacts itself to the value of new member (16 bytes)
// contacts became Null here. Its destruction is trivial.
}
~~~
~~~~~~~
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment