From 3c47ae9fe47b39ea1073b7598c77dbf7abe94fd1 Mon Sep 17 00:00:00 2001 From: Mateusz Loskot Date: Tue, 30 Jun 2015 11:33:44 +0200 Subject: [PATCH] Add to FAQ: How to clear-and-minimize a document? Closes #368 --- doc/faq.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/faq.md b/doc/faq.md index b00b4c6..093e8e7 100644 --- a/doc/faq.md +++ b/doc/faq.md @@ -102,6 +102,21 @@ Some applications use 64-bit unsigned/signed integers. And these integers cannot be converted into `double` without loss of precision. So the parsers detects whether a JSON number is convertible to different types of integers and/or `double`. +8. How to clear-and-minimize a document or value? + +* Call one of the `SetXXX()` methods - they call destructor which deallocates DOM data: + + ``` + Document d; + ... + d.SetObject(); // clear and minimize + ``` + +* Alternatively, use equivalent of the [C++ swap with temporary idiom](https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Clear-and-minimize): + ``` + d.Swap(Value(kObjectType).Move()) + ``` + ## Document/Value (DOM) 1. What is move semantics? Why?