From 97f0314fe63054afc4bb3e7bbd2902308dc61632 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Wed, 8 Feb 2023 21:22:39 +0100 Subject: [PATCH] Saving a few CPU cycles This silly optimization in fact helps to avoid a somewhat more serious waste of CPU cycles that would otherwise result in the next commit. --- src/server/internalServer.cpp | 3 ++- src/server/internalServer.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index 1536e86e6..1513f95a8 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -415,6 +415,7 @@ InternalServer::InternalServer(Library* library, m_addr(addr), m_port(port), m_root(normalizeRootUrl(root)), + m_rootWithSeparator(m_root + "/"), m_nbThreads(nbThreads), m_multizimSearchLimit(multizimSearchLimit), m_verbose(verbose), @@ -519,7 +520,7 @@ MHD_Result InternalServer::handlerCallback(struct MHD_Connection* connection, printf("full_url : %s\n", fullUrl); } - const auto url = fullURL2LocalURL(fullUrl, m_root + "/"); + const auto url = fullURL2LocalURL(fullUrl, m_rootWithSeparator); RequestContext request(connection, m_root, url, method, version); if (m_verbose.load() ) { diff --git a/src/server/internalServer.h b/src/server/internalServer.h index c3990c44d..f00dfe8fb 100644 --- a/src/server/internalServer.h +++ b/src/server/internalServer.h @@ -164,6 +164,7 @@ class InternalServer { std::string m_addr; int m_port; std::string m_root; + std::string m_rootWithSeparator; int m_nbThreads; unsigned int m_multizimSearchLimit; std::atomic_bool m_verbose;