From dd31b870c32abfd46ce95b686841399104f4808f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 2 Apr 2021 14:26:53 -0700 Subject: [PATCH] Remove small pieces of unused code --- gpui/src/platform/mac/mod.rs | 1 + gpui/src/platform/mac/window.rs | 3 --- gpui/src/scene.rs | 4 ---- zed/src/editor/buffer/mod.rs | 4 ---- zed/src/editor/buffer_element.rs | 2 +- zed/src/editor/buffer_view.rs | 1 - zed/src/operation_queue.rs | 5 ----- zed/src/util.rs | 5 ----- zed/src/workspace/workspace.rs | 8 +++----- zed/src/worktree/worktree.rs | 4 +--- 10 files changed, 6 insertions(+), 31 deletions(-) diff --git a/gpui/src/platform/mac/mod.rs b/gpui/src/platform/mac/mod.rs index fc52d0f4188e1fd96a56b880e551eca599c2246f..b7a19c3647a98f97918e85b92ce43ad9001c2844 100644 --- a/gpui/src/platform/mac/mod.rs +++ b/gpui/src/platform/mac/mod.rs @@ -24,6 +24,7 @@ pub fn app() -> impl platform::App { pub fn runner() -> impl platform::Runner { Runner::new() } + trait BoolExt { fn to_objc(self) -> BOOL; } diff --git a/gpui/src/platform/mac/window.rs b/gpui/src/platform/mac/window.rs index 0ae27ec66c290ae54c1c5b87061ddb3781c60820..cf4c617512a41ff663210bb514c0f9ddf0a290c8 100644 --- a/gpui/src/platform/mac/window.rs +++ b/gpui/src/platform/mac/window.rs @@ -126,7 +126,6 @@ struct WindowState { scene_to_render: Option, renderer: Renderer, command_queue: metal::CommandQueue, - device: metal::Device, layer: id, } @@ -189,7 +188,6 @@ impl Window { scene_to_render: Default::default(), renderer: Renderer::new(device.clone(), PIXEL_FORMAT, fonts)?, command_queue: device.new_command_queue(), - device, layer, }))); @@ -426,7 +424,6 @@ extern "C" fn display_layer(this: &Object, _: Sel, _: id) { let size = window_state.size(); let scale_factor = window_state.scale_factor(); - let device = window_state.device.clone(); window_state.renderer.render( &scene, diff --git a/gpui/src/scene.rs b/gpui/src/scene.rs index 49d56b000781f1116fd38921b63024b3a151a0db..d002804dae1e342751b5fc495ef84faf00c72bdf 100644 --- a/gpui/src/scene.rs +++ b/gpui/src/scene.rs @@ -221,10 +221,6 @@ impl Border { self } - fn all_sides(&self) -> bool { - self.top && self.left && self.bottom && self.right - } - pub fn top_width(&self) -> f32 { if self.top { self.width diff --git a/zed/src/editor/buffer/mod.rs b/zed/src/editor/buffer/mod.rs index 1d476ceb27399c83fa57369f221ec64c39c72cb5..94d24f508a3c81bd4f7bd421b7ff8991b108aa09 100644 --- a/zed/src/editor/buffer/mod.rs +++ b/zed/src/editor/buffer/mod.rs @@ -1650,10 +1650,6 @@ impl Fragment { self.text = self.insertion.text.slice(self.start_offset()..offset); } - fn as_str(&self) -> &str { - self.text.as_str() - } - fn visible_len(&self) -> usize { if self.is_visible() { self.len() diff --git a/zed/src/editor/buffer_element.rs b/zed/src/editor/buffer_element.rs index ebb8ecfe791f10adcde23c2573b7c8beb79c9858..a4a9d63a3384f169cd22d98550ff24aedc3f6f14 100644 --- a/zed/src/editor/buffer_element.rs +++ b/zed/src/editor/buffer_element.rs @@ -8,7 +8,7 @@ use gpui::{ }, text_layout::{self, TextLayoutCache}, AfterLayoutContext, AppContext, Border, Element, Event, EventContext, FontCache, LayoutContext, - MutableAppContext, PaintContext, Quad, Scene, SizeConstraint, ViewHandle, + PaintContext, Quad, Scene, SizeConstraint, ViewHandle, }; use smallvec::SmallVec; use std::cmp::Ordering; diff --git a/zed/src/editor/buffer_view.rs b/zed/src/editor/buffer_view.rs index 7b5f1270f38911937b4bea39f4b01e5552cc2d66..7d538b88f495d67b0bc9a76be84a157509f95e83 100644 --- a/zed/src/editor/buffer_view.rs +++ b/zed/src/editor/buffer_view.rs @@ -4,7 +4,6 @@ use super::{ }; use crate::{settings::Settings, watch, workspace}; use anyhow::Result; -use easy_parallel::Parallel; use gpui::{ fonts::Properties as FontProperties, keymap::Binding, text_layout, App, AppContext, Element, ElementBox, Entity, FontCache, ModelHandle, View, ViewContext, WeakViewHandle, diff --git a/zed/src/operation_queue.rs b/zed/src/operation_queue.rs index e3a05323322a5fabaf5716b2fe12c35cfa74894a..baad04b0bfa1137ce9a8a2b0eb120ae2da2df53b 100644 --- a/zed/src/operation_queue.rs +++ b/zed/src/operation_queue.rs @@ -28,11 +28,6 @@ impl OperationQueue { OperationQueue(SumTree::new()) } - #[cfg(test)] - pub fn is_empty(&self) -> bool { - self.0.is_empty() - } - pub fn len(&self) -> usize { self.0.summary().len } diff --git a/zed/src/util.rs b/zed/src/util.rs index 80ff736d24a08ce0fcaefa260619f27e008cdcb2..70f2b1a6d6485445862042fe749ca6d69714b23d 100644 --- a/zed/src/util.rs +++ b/zed/src/util.rs @@ -1,11 +1,6 @@ use rand::prelude::*; use std::cmp::Ordering; -pub fn pre_inc(value: &mut usize) -> usize { - *value += 1; - *value -} - pub fn post_inc(value: &mut usize) -> usize { let prev = *value; *value += 1; diff --git a/zed/src/workspace/workspace.rs b/zed/src/workspace/workspace.rs index 53c5088122ee6e3ac8fabb8be67377f133506a3f..092144791c0da52cee98fda778fd781d590ad534 100644 --- a/zed/src/workspace/workspace.rs +++ b/zed/src/workspace/workspace.rs @@ -7,9 +7,7 @@ use crate::{ worktree::{Worktree, WorktreeHandle as _}, }; use anyhow::anyhow; -use gpui::{ - App, AppContext, Entity, Handle, ModelContext, ModelHandle, MutableAppContext, ViewContext, -}; +use gpui::{AppContext, Entity, Handle, ModelContext, ModelHandle, MutableAppContext, ViewContext}; use smol::prelude::*; use std::{ collections::{HashMap, HashSet}, @@ -202,12 +200,12 @@ impl Entity for Workspace { #[cfg(test)] pub trait WorkspaceHandle { - fn file_entries(&self, app: &App) -> Vec<(usize, usize)>; + fn file_entries(&self, app: &gpui::App) -> Vec<(usize, usize)>; } #[cfg(test)] impl WorkspaceHandle for ModelHandle { - fn file_entries(&self, app: &App) -> Vec<(usize, usize)> { + fn file_entries(&self, app: &gpui::App) -> Vec<(usize, usize)> { self.read(&app, |w, app| { w.worktrees() .iter() diff --git a/zed/src/worktree/worktree.rs b/zed/src/worktree/worktree.rs index ab8d41c46b5acd3b3f1c1952ea5b2353056fa2c4..f4c956508dd328dd33347e3db5e253785fc16d4b 100644 --- a/zed/src/worktree/worktree.rs +++ b/zed/src/worktree/worktree.rs @@ -60,10 +60,8 @@ impl Worktree { tree.0.write().scanning = true; let tree = tree.clone(); - let (tx, rx) = smol::channel::bounded(1); - let task = ctx.background_executor().spawn(async move { - let _ = tx.send(tree.scan_dirs()?).await; + tree.scan_dirs()?; Ok(()) });