From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 613D81FF09C for ; Mon, 02 Nov 2026 15:12:27 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id B208821511; Mon, 02 Nov 2026 15:12:26 +0100 (CET) Message-ID: <9476957c-b5ea-4957-abb1-abca4e8ad1e5@proxmox.com> Date: Mon, 2 Nov 2026 15:12:20 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH proxmox-yew-widget-toolkit 1/5] widget: data table: simplify lookup of keys near the cursor To: Nicolas Frey , yew-devel@lists.proxmox.com References: <20261028151517.518742-1-n.frey@proxmox.com> <20261028151517.518742-2-n.frey@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: <20261028151517.518742-2-n.frey@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793628741023 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.333 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: HCOZ5GB5O5UODLBOF343PT5U55W6UYQY X-Message-ID-Hash: HCOZ5GB5O5UODLBOF343PT5U55W6UYQY X-MailFrom: d.csapak@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: Reviewed-by: Dominik Csapak On 10/28/26 4:15 PM, Nicolas Frey wrote: > 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)