]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/acl/StringData.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / acl / StringData.cc
index 59a03f233b35c1f377b383146f91008069df1b4c..3bec669a2ca770d00b448c8da4cb0d93150bfc3a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -11,7 +11,7 @@
 #include "squid.h"
 #include "acl/Checklist.h"
 #include "acl/StringData.h"
-#include "cache_cf.h"
+#include "ConfigParser.h"
 #include "Debug.h"
 
 ACLStringData::ACLStringData(ACLStringData const &old) : stringValues(old.stringValues)
@@ -25,12 +25,11 @@ ACLStringData::insert(const char *value)
 }
 
 bool
-ACLStringData::match(char const *toFind)
+ACLStringData::match(const SBuf &tf)
 {
-    if (stringValues.empty() || !toFind)
+    if (stringValues.empty() || tf.isEmpty())
         return 0;
 
-    SBuf tf(toFind);
     debugs(28, 3, "aclMatchStringList: checking '" << tf << "'");
 
     bool found = (stringValues.find(tf) != stringValues.end());
@@ -39,6 +38,13 @@ ACLStringData::match(char const *toFind)
     return found;
 }
 
+// XXX: performance regression due to SBuf(char*) data-copies.
+bool
+ACLStringData::match(char const *toFind)
+{
+    return match(SBuf(toFind));
+}
+
 SBufList
 ACLStringData::dump() const
 {
@@ -50,8 +56,7 @@ ACLStringData::dump() const
 void
 ACLStringData::parse()
 {
-    char *t;
-    while ((t = strtokFile()))
+    while (const char *t = ConfigParser::strtokFile())
         stringValues.insert(SBuf(t));
 }