Skip to content

Commit d8a57f3

Browse files
Fix overlocking for workspace cache (#1482)
The lock was held while parsing the workspace which is not necessary and can cause slowness for concurrent requests. Change: fix-ws-overlock
1 parent 609868d commit d8a57f3

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

josh-core/src/filter/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,7 @@ fn get_workspace<'a>(repo: &'a git2::Repository, tree: &'a git2::Tree<'a>, path:
590590
.id();
591591
let ws_blob = tree::get_blob(repo, tree, &ws_path);
592592

593-
let mut workspaces = WORKSPACES.lock().unwrap();
594-
595-
if let Some(f) = workspaces.get(&ws_id) {
593+
if let Some(f) = WORKSPACES.lock().unwrap().get(&ws_id) {
596594
*f
597595
} else {
598596
let f = parse::parse(&ws_blob).unwrap_or_else(|_| to_filter(Op::Empty));
@@ -602,7 +600,7 @@ fn get_workspace<'a>(repo: &'a git2::Repository, tree: &'a git2::Tree<'a>, path:
602600
} else {
603601
to_filter(Op::Empty)
604602
};
605-
workspaces.insert(ws_id, f);
603+
WORKSPACES.lock().unwrap().insert(ws_id, f);
606604
f
607605
}
608606
}

0 commit comments

Comments
 (0)