Lots of performance improvements
(In the voice of the kid from sixth sense) I see string copies...
Apparently there are a lot of places we make unnecessary copies. This
fixes all of them.
Not sure how to split this up into smaller patches, or if it even needs
split up. It seems pretty easy to review to me, because basically every
diff is identical.
Change-Id: I22b4ae4f96f7e4082d2bc701098a04f7bed95369
Signed-off-by: Ed Tanous <ed@tanous.net>
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
diff --git a/http/app.h b/http/app.h
index 86cebd3..39829cb 100644
--- a/http/app.h
+++ b/http/app.h
@@ -80,7 +80,7 @@
App& bindaddr(std::string bindaddr)
{
- bindaddrStr = bindaddr;
+ bindaddrStr = std::move(bindaddr);
return *this;
}
diff --git a/http/http_server.h b/http/http_server.h
index c26e9e0..0ca7dea 100644
--- a/http/http_server.h
+++ b/http/http_server.h
@@ -37,12 +37,12 @@
ioService(std::move(io)),
acceptor(std::move(acceptorIn)),
signals(*ioService, SIGINT, SIGTERM, SIGHUP), timer(*ioService),
- handler(handlerIn), adaptorCtx(adaptor_ctx)
+ handler(handlerIn), adaptorCtx(std::move(adaptor_ctx))
{}
Server(Handler* handlerIn, const std::string& bindaddr, uint16_t port,
- std::shared_ptr<boost::asio::ssl::context> adaptor_ctx,
- std::shared_ptr<boost::asio::io_context> io =
+ const std::shared_ptr<boost::asio::ssl::context>& adaptor_ctx,
+ const std::shared_ptr<boost::asio::io_context>& io =
std::make_shared<boost::asio::io_context>()) :
Server(handlerIn,
std::make_unique<boost::asio::ip::tcp::acceptor>(
@@ -52,8 +52,8 @@
{}
Server(Handler* handlerIn, int existing_socket,
- std::shared_ptr<boost::asio::ssl::context> adaptor_ctx,
- std::shared_ptr<boost::asio::io_context> io =
+ const std::shared_ptr<boost::asio::ssl::context>& adaptor_ctx,
+ const std::shared_ptr<boost::asio::io_context>& io =
std::make_shared<boost::asio::io_context>()) :
Server(handlerIn,
std::make_unique<boost::asio::ip::tcp::acceptor>(
diff --git a/http/routing.h b/http/routing.h
index 52d1b06..59fa636 100644
--- a/http/routing.h
+++ b/http/routing.h
@@ -403,7 +403,7 @@
return *p;
}
- self_t& name(std::string name) noexcept
+ self_t& name(const std::string& name) noexcept
{
self_t* self = static_cast<self_t*>(this);
self->nameStr = std::move(name);
@@ -522,7 +522,7 @@
public:
using self_t = TaggedRule<Args...>;
- TaggedRule(std::string ruleIn) : BaseRule(std::move(ruleIn))
+ TaggedRule(const std::string& ruleIn) : BaseRule(std::move(ruleIn))
{}
void validate() override
@@ -613,7 +613,7 @@
}
template <typename Func>
- void operator()(std::string name, Func&& f)
+ void operator()(const std::string& name, Func&& f)
{
nameStr = std::move(name);
(*this).template operator()<Func>(std::forward(f));