From 0461cb770c3226e4e69b98e82326647607be3dd2 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Wed, 17 Dec 2025 12:04:17 -0500 Subject: [PATCH] Avoid unncessary copying of request and response objects (#2310) --- httplib.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/httplib.h b/httplib.h index 114d60b..5a5aa00 100644 --- a/httplib.h +++ b/httplib.h @@ -6157,8 +6157,8 @@ inline bool redirect(T &cli, Request &req, Response &res, auto ret = cli.send(new_req, new_res, error); if (ret) { - req = new_req; - res = new_res; + req = std::move(new_req); + res = std::move(new_res); if (res.location.empty()) { res.location = location; } } @@ -10554,7 +10554,7 @@ inline bool ClientImpl::handle_request(Stream &strm, Request &req, auto req2 = req; req2.path = "http://" + host_and_port_ + req.path; ret = process_request(strm, req2, res, close_connection, error); - req = req2; + req = std::move(req2); req.path = req_save.path; } else { ret = process_request(strm, req, res, close_connection, error); @@ -10606,7 +10606,7 @@ inline bool ClientImpl::handle_request(Stream &strm, Request &req, Response new_res; ret = send(new_req, new_res, error); - if (ret) { res = new_res; } + if (ret) { res = std::move(new_res); } } } }