From: Francesco Chemolli Date: Fri, 31 Jul 2015 10:28:59 +0000 (+0200) Subject: Comment out dead code, start using LookupTable for HttpHeader lookups. X-Git-Tag: merge-candidate-3-v1~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bffa1d6a482cb7662380751ca72865c5347ba25a;p=thirdparty%2Fsquid.git Comment out dead code, start using LookupTable for HttpHeader lookups. --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index d587ccdb0b..b1267ae1d3 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -162,7 +162,7 @@ static const HttpHeaderFieldAttrs HeadersAttrs[] = { /* TODO: * DONE 1. shift HDR_BAD_HDR to end of enum * 2. shift headers data array to http/RegistredHeaders.cc - * 3. creatign LookupTable object from teh enum and array + * DONE 3. creatign LookupTable object from teh enum and array * (with HDR_BAD_HDR as invalid value) * 4. replacing httpHeaderIdByName() uses with the lookup table * 5. merge HDR_BAD_HDR and HDR_ENUM_END into one thing @@ -1966,20 +1966,31 @@ httpHeaderIdByName(const char *name, size_t name_len, const HttpHeaderFieldInfo return HDR_BAD_HDR; } +http_hdr_type +httpHeaderIdByNameDef(const SBuf &name) +{ + return headerLookupTable.lookup(name); +} + http_hdr_type httpHeaderIdByNameDef(const char *name, int name_len) { + return headerLookupTable.lookup(SBuf(name,name_len)); +#if 0 if (!Headers) Headers = httpHeaderBuildFieldsInfo(HeadersAttrs, HDR_ENUM_END); return httpHeaderIdByName(name, name_len, Headers, HDR_ENUM_END); +#endif } const char * httpHeaderNameById(int id) { +#if 0 if (!Headers) Headers = httpHeaderBuildFieldsInfo(HeadersAttrs, HDR_ENUM_END); +#endif assert(id >= 0 && id < HDR_ENUM_END); diff --git a/src/HttpHeaderTools.h b/src/HttpHeaderTools.h index 822d93f66d..1550d0fdcb 100644 --- a/src/HttpHeaderTools.h +++ b/src/HttpHeaderTools.h @@ -118,6 +118,7 @@ int httpHeaderParseOffset(const char *start, int64_t * off); HttpHeaderFieldInfo *httpHeaderBuildFieldsInfo(const HttpHeaderFieldAttrs * attrs, int count); void httpHeaderDestroyFieldsInfo(HttpHeaderFieldInfo * info, int count); http_hdr_type httpHeaderIdByName(const char *name, size_t name_len, const HttpHeaderFieldInfo * attrs, int end); +http_hdr_type httpHeaderIdByNameDef(const SBuf &name); http_hdr_type httpHeaderIdByNameDef(const char *name, int name_len); const char *httpHeaderNameById(int id); int httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive); diff --git a/src/acl/HttpHeaderData.cc b/src/acl/HttpHeaderData.cc index 7b27e3f6fa..ff8cb14b59 100644 --- a/src/acl/HttpHeaderData.cc +++ b/src/acl/HttpHeaderData.cc @@ -76,7 +76,7 @@ ACLHTTPHeaderData::parse() char* t = ConfigParser::strtokFile(); assert (t != NULL); hdrName = t; - hdrId = httpHeaderIdByNameDef(hdrName.rawBuf(), hdrName.size()); + hdrId = httpHeaderIdByNameDef(SBuf(hdrName)); regex_rule->parse(); }