-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http: Adding flexible remove function to HeaderMap #3186
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -464,6 +464,17 @@ void HeaderMapImpl::remove(const LowerCaseString& key) { | |
} | ||
} | ||
|
||
void HeaderMapImpl::remove(const std::regex& regex) { | ||
for (auto i = headers_.begin(); i != headers_.end();) { | ||
absl::string_view key = i->key().getStringView(); | ||
if (std::regex_search(key.begin(), key.end(), regex)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider std::list::remove_if ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hah - just converted over and got Matt's comment about inline headers. I think the additional complexity to remove the constant time references may make this version preferable. Will look though! |
||
i = headers_.erase(i); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is not going to work correctly if this is a match of an inline header. You are probably going to need to do some extra work to make it work... Can you add a test case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And my intuition of "I should wait an hour and see what Matt thinks" pans out once again :-D |
||
} else { | ||
++i; | ||
} | ||
} | ||
} | ||
|
||
HeaderMapImpl::HeaderEntryImpl& HeaderMapImpl::maybeCreateInline(HeaderEntryImpl** entry, | ||
const LowerCaseString& key) { | ||
if (*entry) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider doing a prefix version? I suspect the regex version is going to be slower, even if heavily tuned and basically a prefix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me. I'd be inclined to then swap regex for prefix as I have 3 confirmed users of prefixes and 0 that need generic regex :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got inline fixed - one more push and I'll do this swap as well