Dean Michael Berris wrote:
> On Fri, May 28, 2010 at 12:42 AM, Nelson, Erik - 2 wrote:
>> if I call http::client.post() with a payload (body), it looks to me like
>> that body gets fully copied at least 5 times in cpp-netlib before it
>> goes down the wire if I understand correctly.

> Hmmm... That's odd. Are you just looking at the code or are you
> tracing that the message is being copied 5 times?

Tracing it (Visual Studio 2008, debug mode, apologies for any mistakes-not 
everything is clear to me)... if I call 

http::client::post (request request_, string_type const & content_type, 
string_type const & body_) {
body(body_) calls impl::body_directive body(std::string body_) which makes a 
copy (1) in its signature
impl::body() creates a struct impl::body_directive which makes two copies, one 
in the constructor signature (2) and another as its private member (3)

request_ << body(body_) calls impl::body_directive operator(), which makes a 
copy by way of string::operator= (4)

http::client::post calls http::client::post(request_), which calls 
http::client::sync_request_skeleton
http::client::sync_request_skeleton calls 
simple_connection_policy::connection_impl::send_request, which makes a deep 
copy of the entire request in the function signature (5)
simple_connection_policy::connection_impl::send_request  calls 
http_sync_connection::send_request_impl
http_sync_connection::send_request_impl  calls 
detail::connection_helper::create_request, which makes a deep copy of the 
entire request in the function signature (6)
detail::connection_helper::create_request makes another copy (7) in the line 
'string_type body_ = body(request_);' and another copy is streamed into 
request_stream (8)

so that's 8 copies inside cpp-netlib by my count, nine if you include the 
original body string that I passed in.  Some of them might be optimized away by 
the compiler under some settings, but that's how it looks to me.

> Are you trying with the latest in master or with a
> previous release of the library?

Latest in master, checked out last week.

Erik

------------------------------------------------------------------------------

_______________________________________________
Cpp-netlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel

Reply via email to