aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorWulan Seruniati Salim <103485830+wulanseruniati@users.noreply.github.com>2024-12-22 18:14:57 +0700
committerGitHub <noreply@github.com>2024-12-22 11:14:57 +0000
commit2ab66ce67870acfff7bf18087421013475411380 (patch)
tree717d7b1aa1769d7fe38061d1d097df69b1b6bdac /components
parentb4bea0daf629ab5284cff86bad2fc9d90e05681f (diff)
downloadservo-2ab66ce67870acfff7bf18087421013475411380.tar.gz
servo-2ab66ce67870acfff7bf18087421013475411380.zip
Optimize mutex usage in fetch by locking once and using scoped MutexGuard (#34737)
Signed-off-by: Wulan Seruniati Salim <wulanseruniati@gmail.com>
Diffstat (limited to 'components')
-rw-r--r--components/net/fetch/methods.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs
index 9a7d5d203ff..3b1474c713c 100644
--- a/components/net/fetch/methods.rs
+++ b/components/net/fetch/methods.rs
@@ -101,17 +101,11 @@ pub type DoneChannel = Option<(TokioSender<Data>, TokioReceiver<Data>)>;
pub async fn fetch(request: &mut Request, target: Target<'_>, context: &FetchContext) {
// Steps 7,4 of https://w3c.github.io/resource-timing/#processing-model
// rev order okay since spec says they're equal - https://w3c.github.io/resource-timing/#dfn-starttime
- context
- .timing
- .lock()
- .unwrap()
- .set_attribute(ResourceAttribute::FetchStart);
- context
- .timing
- .lock()
- .unwrap()
- .set_attribute(ResourceAttribute::StartTime(ResourceTimeValue::FetchStart));
-
+ {
+ let mut timing_guard = context.timing.lock().unwrap();
+ timing_guard.set_attribute(ResourceAttribute::FetchStart);
+ timing_guard.set_attribute(ResourceAttribute::StartTime(ResourceTimeValue::FetchStart));
+ }
fetch_with_cors_cache(request, &mut CorsCache::default(), target, context).await;
}