From 6986e1ac24ce3db606c1ea56308569a8c85f480a Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 8 May 2025 13:42:21 +0800 Subject: [PATCH] code_style: calculate bounds only when it is needed Signed-off-by: leo --- src/Views/CommitGraph.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Views/CommitGraph.cs b/src/Views/CommitGraph.cs index c5baa0ae..5db39300 100644 --- a/src/Views/CommitGraph.cs +++ b/src/Views/CommitGraph.cs @@ -55,11 +55,6 @@ namespace SourceGit.Views if (list == null) return; - // Calculate drawing area. - var width = histories.CommitListHeader.ColumnDefinitions[0].ActualWidth; - var height = Bounds.Height; - - // Calculate row height var container = list.ItemsPanelRoot as VirtualizingStackPanel; if (container == null) return; @@ -68,15 +63,15 @@ namespace SourceGit.Views if (item == null) return; + var width = histories.CommitListHeader.ColumnDefinitions[0].ActualWidth; + var height = Bounds.Height; var rowHeight = item.Bounds.Height; var startY = container.FirstRealizedIndex * rowHeight - item.TranslatePoint(new Point(0, 0), list).Value!.Y; var endY = startY + height + 28; - // Apply scroll offset and clip. using (context.PushClip(new Rect(0, 0, width, height))) using (context.PushTransform(Matrix.CreateTranslation(0, -startY))) { - // Draw contents DrawCurves(context, graph, startY, endY, rowHeight); DrawAnchors(context, graph, startY, endY, rowHeight); }