From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 73F751FF0B3 for ; Wed, 28 Oct 2026 16:15:22 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 38D5421253; Wed, 28 Oct 2026 16:15:22 +0100 (CET) From: Nicolas Frey To: yew-devel@lists.proxmox.com Subject: [PATCH proxmox-yew-widget-toolkit 1/5] widget: data table: simplify lookup of keys near the cursor Date: Wed, 28 Oct 2026 16:15:11 +0100 Message-ID: <20261028151517.518742-2-n.frey@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261028151517.518742-1-n.frey@proxmox.com> References: <20261028151517.518742-1-n.frey@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793200517337 X-SPAM-LEVEL: Spam detection results: 0 AWL 1.332 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: XD6AOQ7GKONDZ55NWEP4XXON652JLV7U X-Message-ID-Hash: XD6AOQ7GKONDZ55NWEP4XXON652JLV7U X-MailFrom: n.frey@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Yew framework devel list at Proxmox List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Nicolas Frey --- src/widget/data_table/data_table.rs | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/widget/data_table/data_table.rs b/src/widget/data_table/data_table.rs index 5d04173..e846522 100644 --- a/src/widget/data_table/data_table.rs +++ b/src/widget/data_table/data_table.rs @@ -620,27 +620,16 @@ impl PwtDataTable { // avoid slow search by lookup up keys nearby cursor first fn filtered_record_pos(&self, props: &DataTable, key: &Key) -> Option { if let Some(Cursor { pos, .. }) = &self.cursor { - let test_pos = *pos; - if let Some(record_key) = props.store.lookup_filtered_record_key(test_pos) { - if &record_key == key { + for test_pos in [Some(*pos), pos.checked_add(1), pos.checked_sub(1)] + .into_iter() + .flatten() + { + if let Some(record_key) = props.store.lookup_filtered_record_key(test_pos) + && &record_key == key + { return Some(test_pos); } } - - let test_pos = pos + 1; - if let Some(record_key) = props.store.lookup_filtered_record_key(test_pos) { - if &record_key == key { - return Some(test_pos); - } - } - if *pos > 0 { - let test_pos = pos - 1; - if let Some(record_key) = props.store.lookup_filtered_record_key(test_pos) { - if &record_key == key { - return Some(test_pos); - } - } - } } props.store.filtered_record_pos(key) -- 2.47.3