]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Refactor Ssl::ErrorDetailsManager to use SBuf (#1556)
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Thu, 2 Nov 2023 01:42:21 +0000 (01:42 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 2 Nov 2023 03:42:18 +0000 (03:42 +0000)
Have Ssl::ErrorDetailsList use SBuf instead of String, and
ErrorDetailsManager::cache index on SBuf and not std::string

src/ssl/ErrorDetailManager.cc
src/ssl/ErrorDetailManager.h

index e2049aff933c0af2bdc11d42a64c2bd622dad4e4..c7489f7ee9e4fff8c675026c175cbdfe9f939896 100644 (file)
@@ -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;
 }
index efef66d38c781c8fb8a737db7a80af17d9034caf..b7ce15972b980bdd9ea9425c1f7dbf200df8a9f1 100644 (file)
 #include "base/RefCount.h"
 #include "HttpRequest.h"
 #include "sbuf/SBuf.h"
-#include "SquidString.h"
 #include "ssl/support.h"
 
 #include <map>
-#include <string>
 
 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<Security::ErrorCode, ErrorDetailEntry> 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<std::string, ErrorDetailsList::Pointer> Cache;
+    using Cache = std::map<SBuf, ErrorDetailsList::Pointer>;
     mutable Cache cache; ///< the error details list cache
     ErrorDetailsList::Pointer theDefaultErrorDetails; ///< the default error details list