aboutsummaryrefslogtreecommitdiffhomepage
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
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.
-rw-r--r--.bleep2
-rw-r--r--pingora-http/src/lib.rs9
2 files changed, 7 insertions, 4 deletions
diff --git a/.bleep b/.bleep
index 40e8ff5..07aa38f 100644
--- a/.bleep
+++ b/.bleep
@@ -1 +1 @@
-6fa02eb9204012fc468cf1cea6ee4042dfdaec9d \ No newline at end of file
+a06136947618424b0ffa3b5c1a280db6a4b577dc \ No newline at end of file
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]