]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Reworked initializers in HttpDigestFieldAttrs
authorFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 23 Jul 2015 20:04:46 +0000 (22:04 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 23 Jul 2015 20:04:46 +0000 (22:04 +0200)
src/auth/digest/Config.cc

index 0bf6aecd906b143184725d0fddccbaaaa56206ba..f68a72296c4ee673f1df457d3f3619e345c9791e 100644 (file)
@@ -64,24 +64,22 @@ enum http_digest_attr_type {
     DIGEST_RESPONSE,
     DIGEST_ENUM_END
 };
+
 struct HttpDigestFieldAttrs {
     const char *name;
     http_digest_attr_type id;
-    HttpDigestFieldAttrs() : name(nullptr), id(DIGEST_ENUM_END) {}
-    HttpDigestFieldAttrs(const char *aName, http_digest_attr_type anId) :
-        name(aName), id(anId)
-    {}
 };
-static const HttpDigestFieldAttrs DigestAttrs[DIGEST_ENUM_END] = {
-    HttpDigestFieldAttrs("username",  DIGEST_USERNAME),
-    HttpDigestFieldAttrs("realm", DIGEST_REALM),
-    HttpDigestFieldAttrs("qop", DIGEST_QOP),
-    HttpDigestFieldAttrs("algorithm", DIGEST_ALGORITHM),
-    HttpDigestFieldAttrs("uri", DIGEST_URI),
-    HttpDigestFieldAttrs("nonce", DIGEST_NONCE),
-    HttpDigestFieldAttrs("nc", DIGEST_NC),
-    HttpDigestFieldAttrs("cnonce", DIGEST_CNONCE),
-    HttpDigestFieldAttrs("response", DIGEST_RESPONSE),
+
+static const HttpDigestFieldAttrs DigestAttrs[] = {
+    {"username",  DIGEST_USERNAME},
+    {"realm", DIGEST_REALM},
+    {"qop", DIGEST_QOP},
+    {"algorithm", DIGEST_ALGORITHM},
+    {"uri", DIGEST_URI},
+    {"nonce", DIGEST_NONCE},
+    {"nc", DIGEST_NC},
+    {"cnonce", DIGEST_CNONCE},
+    {"response", DIGEST_RESPONSE}
 };
 
 /* a SBuf -> http_digest_attr_type lookup table.
@@ -98,9 +96,8 @@ private:
     lookupTable_t lookupTable;
 };
 DigestFieldsLookupTable_t::DigestFieldsLookupTable_t() {
-    for (int i = 0; i < DIGEST_ENUM_END; ++i) {
-        const SBuf s(DigestAttrs[i].name);
-        lookupTable[s] = DigestAttrs[i].id;
+    for (auto i : DigestAttrs) {
+        lookupTable[SBuf(i.name)] = i.id;
     }
 }
 inline http_digest_attr_type