Fix #508 tutorial documentation about move semantics.
This commit is contained in:
parent
9515b9cc94
commit
bd1be768f1
@ -280,7 +280,7 @@ A very special decision during design of RapidJSON is that, assignment of value
|
|||||||
~~~~~~~~~~cpp
|
~~~~~~~~~~cpp
|
||||||
Value a(123);
|
Value a(123);
|
||||||
Value b(456);
|
Value b(456);
|
||||||
b = a; // a becomes a Null value, b becomes number 123.
|
a = b; // a becomes number 456, b becomes a Null value.
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
|
||||||

|

|
||||||
@ -305,7 +305,7 @@ Value o(kObjectType);
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
The object `o` needs to allocate a buffer of same size as contacts, makes a deep clone of it, and then finally contacts is destructed. This will incur a lot of unnecessary allocations/deallocations and memory copying.
|
The object `o` needs to allocate a buffer of same size as `contacts`, makes a deep clone of it, and then finally `contacts` is destructed. This will incur a lot of unnecessary allocations/deallocations and memory copying.
|
||||||
|
|
||||||
There are solutions to prevent actual copying these data, such as reference counting and garbage collection(GC).
|
There are solutions to prevent actual copying these data, such as reference counting and garbage collection(GC).
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ Value a(kArrayType);
|
|||||||
~~~~~~~~~~cpp
|
~~~~~~~~~~cpp
|
||||||
Value a(123);
|
Value a(123);
|
||||||
Value b(456);
|
Value b(456);
|
||||||
b = a; // a变成Null,b变成数字123。
|
a = b; // a变成数字456,b变成Null。
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
|
||||||

|

|
||||||
@ -304,7 +304,7 @@ Value o(kObjectType);
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
那个`o` Object需要分配一个和contacts相同大小的缓冲区,对conacts做深度复制,并最终要析构contacts。这样会产生大量无必要的内存分配/释放,以及内存复制。
|
那个`o` Object需要分配一个和contacts相同大小的缓冲区,对`contacts`做深度复制,并最终要析构`contacts`。这样会产生大量无必要的内存分配/释放,以及内存复制。
|
||||||
|
|
||||||
有一些方案可避免实质地复制这些数据,例如引用计数(reference counting)、垃圾回收(garbage collection, GC)。
|
有一些方案可避免实质地复制这些数据,例如引用计数(reference counting)、垃圾回收(garbage collection, GC)。
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user