From 2d2b04b57e8797f9d806ea858b76e46ec664e3ee Mon Sep 17 00:00:00 2001 From: Brandon Thetford Date: Thu, 15 Feb 2024 18:37:49 -0700 Subject: [PATCH] Reference passing to avoid some struct copies --- Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs | 2 +- Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs | 2 +- Terminal.Gui/Drawing/Attribute.cs | 8 +++----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs index 31b2ce50e..f09767dba 100644 --- a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs @@ -520,7 +520,7 @@ public abstract class ConsoleDriver /// The foreground color. /// The background color. /// The attribute for the foreground and background colors. - public virtual Attribute MakeColor (Color foreground, Color background) + public virtual Attribute MakeColor (in Color foreground, in Color background) { // Encode the colors into the int value. return new Attribute ( diff --git a/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs b/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs index 73dad8fe5..2dc72d167 100644 --- a/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs @@ -835,7 +835,7 @@ internal class CursesDriver : ConsoleDriver /// bits, and the background color is stored in the least significant 4 bits. The Terminal.GUi Color values are /// converted to curses color encoding before being encoded. /// - public override Attribute MakeColor (Color foreground, Color background) + public override Attribute MakeColor (in Color foreground, in Color background) { if (!RunningUnitTests) { diff --git a/Terminal.Gui/Drawing/Attribute.cs b/Terminal.Gui/Drawing/Attribute.cs index cf9b9c63b..1d8759d00 100644 --- a/Terminal.Gui/Drawing/Attribute.cs +++ b/Terminal.Gui/Drawing/Attribute.cs @@ -67,7 +67,7 @@ public readonly struct Attribute : IEquatable, IEqualityOperatorsInitializes a new instance of the struct. /// Foreground /// Background - public Attribute (Color foreground, Color background) + public Attribute (in Color foreground, in Color background) { Foreground = foreground; Background = background; @@ -94,10 +94,8 @@ public readonly struct Attribute : IEquatable, IEqualityOperatorsInitializes a new instance of the struct. /// Foreground /// Background - public Attribute (in ColorName foregroundName, in ColorName backgroundName) : this ( - new Color (foregroundName), - new Color (backgroundName) - ) + public Attribute (in ColorName foregroundName, in ColorName backgroundName) + : this (new Color (in foregroundName), new Color (in backgroundName)) { } /// Initializes a new instance of the struct.