aboutsummaryrefslogtreecommitdiffhomepage
path: root/pingora-http
diff options
context:
space:
mode:
authorYuchen Wu <[email protected]>2024-06-07 15:28:39 -0400
committerKevin Guthrie <[email protected]>2024-06-07 15:42:30 -0400
commit53e696d1dde32a9b8094b5fe4c956330462b59a8 (patch)
tree6129ad170b8c652220a9df72abe8e46db3bcd032 /pingora-http
parente3c655b78103316b21abe452a245b3b5f2402ebe (diff)
downloadpingora-53e696d1dde32a9b8094b5fe4c956330462b59a8.tar.gz
pingora-53e696d1dde32a9b8094b5fe4c956330462b59a8.zip
Faster remove_header() call.
It saves one lookup when the header to remove is not in the map. Micro-benchmark shows about 40% speedup.
Diffstat (limited to 'pingora-http')
-rw-r--r--pingora-http/src/lib.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/pingora-http/src/lib.rs b/pingora-http/src/lib.rs
index 74dee53..71f81ee 100644
--- a/pingora-http/src/lib.rs
+++ b/pingora-http/src/lib.rs
@@ -573,10 +573,13 @@ fn remove_header<'a, T, N: ?Sized>(
where
&'a N: 'a + AsHeaderName,
{
- if let Some(name_map) = name_map {
- name_map.remove(name);
+ let removed = value_map.remove(name);
+ if removed.is_some() {
+ if let Some(name_map) = name_map {
+ name_map.remove(name);
+ }
}
- value_map.remove(name)
+ removed
}
#[inline]