Reference passing to avoid some struct copies

This commit is contained in:
Brandon Thetford
2024-02-15 18:37:49 -07:00
parent fa38c9a5f6
commit 2d2b04b57e
3 changed files with 5 additions and 7 deletions

View File

@@ -520,7 +520,7 @@ public abstract class ConsoleDriver
/// <param name="foreground">The foreground color.</param>
/// <param name="background">The background color.</param>
/// <returns>The attribute for the foreground and background colors.</returns>
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 (

View File

@@ -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.
/// </remarks>
public override Attribute MakeColor (Color foreground, Color background)
public override Attribute MakeColor (in Color foreground, in Color background)
{
if (!RunningUnitTests)
{

View File

@@ -67,7 +67,7 @@ public readonly struct Attribute : IEquatable<Attribute>, IEqualityOperators<Att
/// <summary>Initializes a new instance of the <see cref="Attribute"/> struct.</summary>
/// <param name="foreground">Foreground</param>
/// <param name="background">Background</param>
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<Attribute>, IEqualityOperators<Att
/// <summary>Initializes a new instance of the <see cref="Attribute"/> struct.</summary>
/// <param name="foregroundName">Foreground</param>
/// <param name="backgroundName">Background</param>
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))
{ }
/// <summary>Initializes a new instance of the <see cref="Attribute"/> struct.</summary>