From 26d449d6f54547a7da276106c857d8f4f7d84f24 Mon Sep 17 00:00:00 2001 From: Lehonti Ramos <17771375+Lehonti@users.noreply.github.com> Date: Mon, 18 Dec 2023 17:26:44 +0100 Subject: [PATCH] Used compound assignments when appropriate (#618) * Used compound assignments when appropriate * In `CairoExtensions`, swapped values using tuples --- Pinta.Core/Actions/ViewActions.cs | 2 +- Pinta.Core/Extensions/CairoExtensions.cs | 16 +++++----------- Pinta.Effects/Effects/BulgeEffect.cs | 4 ++-- Pinta.Tools/Brushes/CircleBrush.cs | 3 +++ 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Pinta.Core/Actions/ViewActions.cs b/Pinta.Core/Actions/ViewActions.cs index 29600e025..c359cb26b 100644 --- a/Pinta.Core/Actions/ViewActions.cs +++ b/Pinta.Core/Actions/ViewActions.cs @@ -314,7 +314,7 @@ public void UpdateCanvasScale () return; percent = Math.Min (percent, 3600); - percent = percent / 100.0; + percent /= 100.0; PintaCore.Workspace.Scale = percent; } diff --git a/Pinta.Core/Extensions/CairoExtensions.cs b/Pinta.Core/Extensions/CairoExtensions.cs index 454ffa178..38a14dbea 100644 --- a/Pinta.Core/Extensions/CairoExtensions.cs +++ b/Pinta.Core/Extensions/CairoExtensions.cs @@ -657,13 +657,13 @@ public static ColorBgra GetBilinearSampleWrapped (this ImageSurface src, ReadOnl if (sx < 0) sx = (srcWidth - 1) + ((sx + 1) % srcWidth); else if (sx > (srcWidth - 1)) - sx = sx % srcWidth; + sx %= srcWidth; int sy = iv; if (sy < 0) sy = (srcHeight - 1) + ((sy + 1) % srcHeight); else if (sy > (srcHeight - 1)) - sy = sy % srcHeight; + sy %= srcHeight; int sleft = sx; int sright; @@ -727,9 +727,7 @@ public static ImmutableArray GetScans (this ReadOnlySpan point int dy; if (top.Y > bottom.Y) { - PointI temp = top; - top = bottom; - bottom = temp; + (bottom, top) = (top, bottom); } dy = bottom.Y - top.Y; @@ -750,9 +748,7 @@ public static ImmutableArray GetScans (this ReadOnlySpan point min = j; if (min != i) { - Edge temp = edgeTable[min]; - edgeTable[min] = edgeTable[i]; - edgeTable[i] = temp; + (edgeTable[i], edgeTable[min]) = (edgeTable[min], edgeTable[i]); } } @@ -824,9 +820,7 @@ public static ImmutableArray GetScans (this ReadOnlySpan point min = j; if (min != i) { - int temp = active[min]; - active[min] = active[i]; - active[i] = temp; + (active[i], active[min]) = (active[min], active[i]); } } diff --git a/Pinta.Effects/Effects/BulgeEffect.cs b/Pinta.Effects/Effects/BulgeEffect.cs index dd4618880..a9c2a21d7 100644 --- a/Pinta.Effects/Effects/BulgeEffect.cs +++ b/Pinta.Effects/Effects/BulgeEffect.cs @@ -48,8 +48,8 @@ public override void Render (ImageSurface src, ImageSurface dst, ReadOnlySpan