diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-04-23 09:07:41 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-04-23 09:07:41 +0000 |
commit | b35b2344f47ddaef21fb74c7f5cad9cd91d3cb45 (patch) | |
tree | e7b382f5c6cce63ce1e160d51ad1aac846ba2905 /library/cpp/http/io/headers.cpp | |
parent | b3bee3aa6d7c8767695b8917484e6bb488e9c8ca (diff) | |
parent | ae5472d0928c374dc719b154c9dcb2be6e0a0695 (diff) | |
download | ydb-b35b2344f47ddaef21fb74c7f5cad9cd91d3cb45.tar.gz |
Merge branch 'rightlib' into mergelibs-240423-0906
Diffstat (limited to 'library/cpp/http/io/headers.cpp')
-rw-r--r-- | library/cpp/http/io/headers.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/library/cpp/http/io/headers.cpp b/library/cpp/http/io/headers.cpp index 3f3a5a2d07d..9117bc0ba00 100644 --- a/library/cpp/http/io/headers.cpp +++ b/library/cpp/http/io/headers.cpp @@ -12,13 +12,6 @@ static inline TStringBuf Trim(const char* b, const char* e) noexcept { return StripString(TStringBuf(b, e)); } -static inline bool HeaderNameEqual(TStringBuf headerName, TStringBuf expectedName) noexcept { - // Most headers names have distinct sizes. - // Size comparison adds small overhead if all headers have the same size (~4% or lower with size = 4), - // but significantly speeds up the case where sizes are different (~4.5x for expectedName.size() = 4 and headerName.size() = 5) - return headerName.size() == expectedName.size() && AsciiCompareIgnoreCase(headerName, expectedName) == 0; -} - THttpInputHeader::THttpInputHeader(const TStringBuf header) { size_t pos = header.find(':'); @@ -79,7 +72,7 @@ bool THttpHeaders::HasHeader(const TStringBuf header) const { const THttpInputHeader* THttpHeaders::FindHeader(const TStringBuf header) const { for (const auto& hdr : Headers_) { - if (HeaderNameEqual(hdr.Name(), header)) { + if (AsciiEqualsIgnoreCase(hdr.Name(), header)) { return &hdr; } } @@ -88,7 +81,7 @@ const THttpInputHeader* THttpHeaders::FindHeader(const TStringBuf header) const void THttpHeaders::RemoveHeader(const TStringBuf header) { for (auto h = Headers_.begin(); h != Headers_.end(); ++h) { - if (HeaderNameEqual(h->Name(), header)) { + if (AsciiEqualsIgnoreCase(h->Name(), header)) { Headers_.erase(h); return; } @@ -98,7 +91,7 @@ void THttpHeaders::RemoveHeader(const TStringBuf header) { void THttpHeaders::AddOrReplaceHeader(const THttpInputHeader& header) { TStringBuf name = header.Name(); for (auto& hdr : Headers_) { - if (HeaderNameEqual(hdr.Name(), name)) { + if (AsciiEqualsIgnoreCase(hdr.Name(), name)) { hdr = header; return; } |