amorlzu / pugixml

Automatically exported from code.google.com/p/pugixml
0 stars 0 forks source link

xml_document copyable #225

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have read issue #166 and I would like to raise a point that was not discussed 
there just in case it might make a difference. 

The point is that the lack of a copy operation makes a trivial optimization 
like RVO impossible. With RVO, which is implemented widely in compilers 
nowadays, a user would not incur the penalty of a copy in optimized builds and 
allow for a more "functional" style of programming. 

Original issue reported on code.google.com by nikko...@hates.ms on 1 Feb 2014 at 1:18

GoogleCodeExporter commented 9 years ago
The fact that RVO is implemented in many compilers does not really invalidate 
the points raised in the original issue.

RVO is not guaranteed, so from the performance perspective you depend on the 
compiler implementation; enabling copying for the sake of RVO means that all 
other uses become eligible for copying as well, with associated performance and 
correctness issues.

Enabling copying for the sake of RVO is nowadays implemented by moving. Upon 
further reflection my comment in #166 is not entirely correct - it should be 
easy to implement a move ctor that is almost always O(1).

Feel free to open a separate issue for this if you use a C++11 environment and 
believe you can benefit from move support.

Original comment by arseny.k...@gmail.com on 8 Feb 2014 at 11:12