From 408282097f4df04444b87283c5a64e09b8509122 Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Tue, 2 Apr 2024 02:34:20 +0200 Subject: [PATCH] avoid collecting columns to a temporary vec --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- helix-term/src/ui/picker.rs | 13 ++++--------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d8e65a8f3..89c8553c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1779,9 +1779,9 @@ dependencies = [ [[package]] name = "nucleo" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6350a138d8860658523a7593cbf6813999d17a099371d14f70c5c905b37593e9" +checksum = "5262af4c94921c2646c5ac6ff7900c2af9cbb08dc26a797e18130a7019c039d4" dependencies = [ "nucleo-matcher", "parking_lot", diff --git a/Cargo.toml b/Cargo.toml index d9541b648..e7f784428 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ package.helix-term.opt-level = 2 [workspace.dependencies] tree-sitter = { version = "0.22" } -nucleo = "0.4.1" +nucleo = "0.5.0" slotmap = "1.0.7" thiserror = "1.0" diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 1c47552d0..69a87f25b 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -15,7 +15,7 @@ use futures_util::future::BoxFuture; use helix_event::AsyncHook; use nucleo::pattern::{CaseMatching, Normalization}; -use nucleo::{Config, Nucleo, Utf32String}; +use nucleo::{Config, Nucleo}; use thiserror::Error; use tokio::sync::mpsc::Sender; use tui::{ @@ -135,14 +135,9 @@ fn inject_nucleo_item( item: T, editor_data: &D, ) { - let column_texts: Vec = columns - .iter() - .filter(|column| column.filter) - .map(|column| column.format_text(&item, editor_data).into()) - .collect(); - injector.push(item, |dst| { - for (i, text) in column_texts.into_iter().enumerate() { - dst[i] = text; + injector.push(item, |item, dst| { + for (column, text) in columns.iter().filter(|column| column.filter).zip(dst) { + *text = column.format_text(item, editor_data).into() } }); }