Skip to content

Visual Studio Code, rebuilt in Rust

Rust

perf(workbench): skip built-ins in the badge, explorer rows without focus

rokartur42d10fe23477
diff --git a/native/crates/app/src/workbench/explorer_actions.rs b/native/crates/app/src/workbench/explorer_actions.rs
index 9650f55281f..02ac7cc9910 100644
--- a/native/crates/app/src/workbench/explorer_actions.rs
+++ b/native/crates/app/src/workbench/explorer_actions.rs
@@ -308,7 +308,7 @@ impl Workbench {
context.insert("listSupportsMultiselect".into(), json!(true));
context.insert("listHasSelectionOrFocus".into(), json!(tree.focused.is_some() || !tree.selected.is_empty()));
context.insert("listDoubleSelection".into(), json!(tree.selected.len() == 2));
- let rows = tree.rows();
+ let rows = if tree.focused.is_some() { tree.rows() } else { Vec::new() };
let focused_index = tree.focused.as_ref().and_then(|focused| rows.iter().position(|row| row.path == *focused));
if let Some(index) = focused_index {
let row = &rows[index];
@@ -335,7 +335,7 @@ impl Workbench {
context.insert("explorerResourceMoveableToTrash".into(), json!(tree.focused.is_some() && self.setting("files.enableTrash") == json!(true)));
context.insert("explorerResourceCut".into(), json!(tree.cut && !tree.clipboard.is_empty()));
context.insert("fileCopied".into(), json!(tree.file_copied));
- let navigation = tree.focused.as_ref().and_then(|focused| tree.navigation_at(focused));
+ let navigation = focused_index.and_then(|index| tree.navigation(&rows[index]));
context.insert("explorerViewletCompressedFocus".into(), json!(navigation.is_some()));
self.explorer_find_context(context);
if let Some(navigation) = navigation {
diff --git a/native/crates/app/src/workbench/extensions_view.rs b/native/crates/app/src/workbench/extensions_view.rs
index a6c5d6d3dd1..b33942a755f 100644
--- a/native/crates/app/src/workbench/extensions_view.rs
+++ b/native/crates/app/src/workbench/extensions_view.rs
@@ -338,6 +338,11 @@ impl Workbench {
/// The `Extension`s of the installed list (`extensionsWorkbenchService.local`) with their enablement and runtime state.
pub fn local_extensions(&self) -> Vec<Extension> {
+ self.local_extensions_where(|_| true)
+ }
+
+ /// The installed extensions `keep` accepts, as `local_extensions` models them.
+ fn local_extensions_where(&self, keep: impl Fn(&ScannedExtension) -> bool) -> Vec<Extension> {
let viewlet = &self.extensions_viewlet;
let inputs = enablement_inputs(&viewlet.installed, &viewlet.disabled_in_env, viewlet.disable_all_in_env, &viewlet.development, viewlet.bisect.as_ref());
let mut profile = self.profile_storage.lock().unwrap();
@@ -347,6 +352,7 @@ impl Workbench {
.installed
.iter()
.enumerate()
+ .filter(|(_, local)| keep(local))
.map(|(index, local)| {
let state = enablement.state(&inputs, index);
let running = self.extensions.iter().find(|running| running.id.eq_ignore_ascii_case(&local.id));
@@ -1164,7 +1170,9 @@ impl Workbench {
/// StatusUpdater: the outdated enabled extensions plus those needing a restart, and its hover text.
pub(super) fn extensions_badge(&self) -> Option<(usize, String)> {
- let local = self.local_extensions();
+ // A built-in extension is never outdated nor counted as needing a restart; cloning the ~100 built-in
+ // manifests on every frame cost 6% of an editor frame.
+ let local = self.local_extensions_where(|local| local.description["isBuiltin"] != true);
let auto_restart = self.setting("extensions.autoRestart") == true;
let action_required = if auto_restart { 0 } else { local.iter().filter(|extension| extension.restart_required && !extension.is_builtin()).count() };
let outdated = local.iter().filter(|extension| extension.outdated() && extension.enablement.is_enabled() && !extension.restart_required).count();