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 5A1641FF0B4 for ; Fri, 27 Nov 2026 17:13:21 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 47F0D2178B; Fri, 27 Nov 2026 17:13:01 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 15/38] widget: charts: world map: compare the map data by reference Date: Fri, 27 Nov 2026 17:12:12 +0100 Message-ID: <20261127161241.3713494-16-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261127161241.3713494-1-d.csapak@proxmox.com> References: <20261127161241.3713494-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.254 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: XK5USLPGFI3OMXWOYYUQGT2PSIOYY56T X-Message-ID-Hash: XK5USLPGFI3OMXWOYYUQGT2PSIOYY56T 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: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Comparing two `Rc` compares what they point to, which here are the tens of thousands of points of the map. That happened for every render of the parent to see if the properties changed, and again to see if the path of the map has to be calculated anew. Compare the pointers instead. A new `Rc` with the same content now counts as a change, but users of the map keep the one they loaded anyway. Signed-off-by: Dominik Csapak --- src/widget/charts/world_map.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/widget/charts/world_map.rs b/src/widget/charts/world_map.rs index 0fac833..efe6099 100644 --- a/src/widget/charts/world_map.rs +++ b/src/widget/charts/world_map.rs @@ -1,6 +1,7 @@ use std::marker::PhantomData; use std::rc::Rc; +use derivative::Derivative; use geojson::{GeoJson, Geometry}; use yew::prelude::*; @@ -63,7 +64,8 @@ impl From> for MapPoint { /// A world map using GeoJSON data to draw SVG lines and polygons. #[widget(pwt=crate,comp=WorldMapComp, @element)] #[builder] -#[derive(Properties, PartialEq, Clone)] +#[derive(Properties, Derivative, Clone)] +#[derivative(PartialEq)] pub struct WorldMap { #[prop_or_default] /// A list of points to highlight on the map. @@ -79,6 +81,8 @@ pub struct WorldMap { /// The radius for info points. Forwarded to the inner [Map]. info_point_radius: f64, + // the map is big, and it would be compared for every render of the parent otherwise + #[derivative(PartialEq(compare_with = "Rc::ptr_eq"))] map_data: Rc, } @@ -170,7 +174,7 @@ impl yew::Component for WorldMapComp { fn changed(&mut self, ctx: &Context, old_props: &Self::Properties) -> bool { let props = ctx.props(); - if props.map_data != old_props.map_data { + if !Rc::ptr_eq(&props.map_data, &old_props.map_data) { self.path = calculate_path(&props.map_data); } true -- 2.47.3