From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Thu, 2 Nov 2023 01:42:21 +0000 (+0000) Subject: Refactor Ssl::ErrorDetailsManager to use SBuf (#1556) X-Git-Tag: SQUID_7_0_1~300 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aca65b2b0b80f7e79203454a7148d338cc7dbdd4;p=thirdparty%2Fsquid.git Refactor Ssl::ErrorDetailsManager to use SBuf (#1556) Have Ssl::ErrorDetailsList use SBuf instead of String, and ErrorDetailsManager::cache index on SBuf and not std::string --- diff --git a/src/ssl/ErrorDetailManager.cc b/src/ssl/ErrorDetailManager.cc index e2049aff93..c7489f7ee9 100644 --- a/src/ssl/ErrorDetailManager.cc +++ b/src/ssl/ErrorDetailManager.cc @@ -98,7 +98,7 @@ Ssl::ErrorDetailsList::Pointer Ssl::ErrorDetailsManager::getCachedDetails(const char * const lang) const { Cache::iterator it; - it = cache.find(lang); + it = cache.find(SBuf(lang)); if (it != cache.end()) { debugs(83, 8, "Found template details in cache for language: " << lang); return it->second; @@ -110,8 +110,7 @@ Ssl::ErrorDetailsManager::getCachedDetails(const char * const lang) const void Ssl::ErrorDetailsManager::cacheDetails(const ErrorDetailsList::Pointer &errorDetails) const { - const char *lang = errorDetails->errLanguage.termedBuf(); - assert(lang); + const auto &lang = errorDetails->errLanguage; if (cache.find(lang) == cache.end()) cache[lang] = errorDetails; } diff --git a/src/ssl/ErrorDetailManager.h b/src/ssl/ErrorDetailManager.h index efef66d38c..b7ce15972b 100644 --- a/src/ssl/ErrorDetailManager.h +++ b/src/ssl/ErrorDetailManager.h @@ -12,11 +12,9 @@ #include "base/RefCount.h" #include "HttpRequest.h" #include "sbuf/SBuf.h" -#include "SquidString.h" #include "ssl/support.h" #include -#include class HttpRequest; @@ -47,7 +45,7 @@ public: /// is invalidated by any non-constant operation on the list object const ErrorDetailEntry *findRecord(Security::ErrorCode) const; - String errLanguage; ///< The language of the error-details.txt template, if any + SBuf errLanguage; ///< The language of the error-details.txt template, if any typedef std::map ErrorDetails; ErrorDetails theList; ///< The list of error details entries }; @@ -84,7 +82,7 @@ private: /// cache the given error details list. void cacheDetails(const ErrorDetailsList::Pointer &errorDetails) const; - typedef std::map Cache; + using Cache = std::map; mutable Cache cache; ///< the error details list cache ErrorDetailsList::Pointer theDefaultErrorDetails; ///< the default error details list