In pooled_connection.hpp it seems like lots of copies are being made of
the request...
basic_response<Tag> send_request(string_type const & method,
basic_request<Tag> request_, bool get_body)
makes a copy when it is called, and
basic_response<Tag> send_request_impl(string_type const & method,
basic_request<Tag> request_, bool get_body)
Makes another copy when it's called.
If, for example, I do something
string body("hello");
client.put(request, body);
No fewer than four instances of the body string will exist
simultaneously... one copy will be made in client.put(), one in
connection.send_request, and another in connection.send_request_impl
I'm not sure if that's intentional or not but it seems a bit
inefficient. It seems like there need not ever be more than the
original body.
For what it's worth, it might make sense to use boost ranges to specify
the body, thereby decoupling it from the string_type which seems to be
pervasive. The ranges are cheap to copy since they only reference the
actual storage, and they let the user use whatever storage makes sense.
(std::string, char[], vector<char>, boost::array<char>, etc.)
Let me know if you feel like I'm spamming the list... I'm just getting
into embedding a client and server in my app and noticing a few things.
I appreciate the hard work that you put into cpp-netlib.
Erik
|