1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-12 23:55:41 +00:00

Use in modifier where logical to reduce overhead

This commit is contained in:
Oliver Booth 2022-06-01 18:29:41 +01:00
parent 09393029e8
commit 34b4777a8e
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
5 changed files with 38 additions and 38 deletions

View File

@ -107,7 +107,7 @@ public readonly struct Ellipse : IEquatable<Ellipse>
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered equal; otherwise, /// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered equal; otherwise,
/// <see langword="false" />. /// <see langword="false" />.
/// </returns> /// </returns>
public static bool operator ==(Ellipse left, Ellipse right) public static bool operator ==(in Ellipse left, in Ellipse right)
{ {
return left.Equals(right); return left.Equals(right);
} }
@ -121,7 +121,7 @@ public readonly struct Ellipse : IEquatable<Ellipse>
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise, /// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise,
/// <see langword="false" />. /// <see langword="false" />.
/// </returns> /// </returns>
public static bool operator !=(Ellipse left, Ellipse right) public static bool operator !=(in Ellipse left, in Ellipse right)
{ {
return !left.Equals(right); return !left.Equals(right);
} }
@ -131,7 +131,7 @@ public readonly struct Ellipse : IEquatable<Ellipse>
/// </summary> /// </summary>
/// <param name="circle">The circle to convert.</param> /// <param name="circle">The circle to convert.</param>
/// <returns>The converted ellipse.</returns> /// <returns>The converted ellipse.</returns>
public static implicit operator Ellipse(Circle circle) public static implicit operator Ellipse(in Circle circle)
{ {
return new Ellipse(circle.Center, new Size(circle.Radius, circle.Radius)); return new Ellipse(circle.Center, new Size(circle.Radius, circle.Radius));
} }

View File

@ -135,7 +135,7 @@ public readonly struct EllipseF : IEquatable<EllipseF>
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered equal; otherwise, /// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered equal; otherwise,
/// <see langword="false" />. /// <see langword="false" />.
/// </returns> /// </returns>
public static bool operator ==(EllipseF left, EllipseF right) public static bool operator ==(in EllipseF left, in EllipseF right)
{ {
return left.Equals(right); return left.Equals(right);
} }
@ -149,7 +149,7 @@ public readonly struct EllipseF : IEquatable<EllipseF>
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise, /// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise,
/// <see langword="false" />. /// <see langword="false" />.
/// </returns> /// </returns>
public static bool operator !=(EllipseF left, EllipseF right) public static bool operator !=(in EllipseF left, in EllipseF right)
{ {
return !left.Equals(right); return !left.Equals(right);
} }
@ -159,7 +159,7 @@ public readonly struct EllipseF : IEquatable<EllipseF>
/// </summary> /// </summary>
/// <param name="circle">The circle to convert.</param> /// <param name="circle">The circle to convert.</param>
/// <returns>The converted ellipse.</returns> /// <returns>The converted ellipse.</returns>
public static implicit operator EllipseF(Circle circle) public static implicit operator EllipseF(in Circle circle)
{ {
return new EllipseF(circle.Center, new SizeF(circle.Radius, circle.Radius)); return new EllipseF(circle.Center, new SizeF(circle.Radius, circle.Radius));
} }
@ -169,7 +169,7 @@ public readonly struct EllipseF : IEquatable<EllipseF>
/// </summary> /// </summary>
/// <param name="circle">The circle to convert.</param> /// <param name="circle">The circle to convert.</param>
/// <returns>The converted ellipse.</returns> /// <returns>The converted ellipse.</returns>
public static implicit operator EllipseF(CircleF circle) public static implicit operator EllipseF(in CircleF circle)
{ {
return new EllipseF(circle.Center, new SizeF(circle.Radius, circle.Radius)); return new EllipseF(circle.Center, new SizeF(circle.Radius, circle.Radius));
} }
@ -179,7 +179,7 @@ public readonly struct EllipseF : IEquatable<EllipseF>
/// </summary> /// </summary>
/// <param name="ellipse">The ellipse to convert.</param> /// <param name="ellipse">The ellipse to convert.</param>
/// <returns>The converted ellipse.</returns> /// <returns>The converted ellipse.</returns>
public static implicit operator EllipseF(Ellipse ellipse) public static implicit operator EllipseF(in Ellipse ellipse)
{ {
return new EllipseF(ellipse.Center, ellipse.Radius); return new EllipseF(ellipse.Center, ellipse.Radius);
} }
@ -189,7 +189,7 @@ public readonly struct EllipseF : IEquatable<EllipseF>
/// </summary> /// </summary>
/// <param name="ellipse">The ellipse to convert.</param> /// <param name="ellipse">The ellipse to convert.</param>
/// <returns>The converted ellipse.</returns> /// <returns>The converted ellipse.</returns>
public static explicit operator Ellipse(EllipseF ellipse) public static explicit operator Ellipse(in EllipseF ellipse)
{ {
PointF center = ellipse.Center; PointF center = ellipse.Center;
return new Ellipse((int)center.X, (int)center.Y, (int)ellipse.HorizontalRadius, (int)ellipse.VerticalRadius); return new Ellipse((int)center.X, (int)center.Y, (int)ellipse.HorizontalRadius, (int)ellipse.VerticalRadius);

View File

@ -69,15 +69,15 @@ public readonly struct Line : IEquatable<Line>, IComparable<Line>, IComparable
public Point Start { get; } public Point Start { get; }
/// <summary> /// <summary>
/// Returns a value indicating whether two instances of <see cref="Line" /> are not equal. /// Returns a value indicating whether two instances of <see cref="Line" /> are equal.
/// </summary> /// </summary>
/// <param name="left">The first instance.</param> /// <param name="left">The first instance.</param>
/// <param name="right">The second instance.</param> /// <param name="right">The second instance.</param>
/// <returns> /// <returns>
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise, /// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered equal; otherwise,
/// <see langword="false" />. /// <see langword="false" />.
/// </returns> /// </returns>
public static bool operator ==(Line left, Line right) public static bool operator ==(in Line left, in Line right)
{ {
return left.Equals(right); return left.Equals(right);
} }
@ -91,7 +91,7 @@ public readonly struct Line : IEquatable<Line>, IComparable<Line>, IComparable
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise, /// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise,
/// <see langword="false" />. /// <see langword="false" />.
/// </returns> /// </returns>
public static bool operator !=(Line left, Line right) public static bool operator !=(in Line left, in Line right)
{ {
return !left.Equals(right); return !left.Equals(right);
} }
@ -105,7 +105,7 @@ public readonly struct Line : IEquatable<Line>, IComparable<Line>, IComparable
/// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is less than that of /// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is less than that of
/// <paramref name="right" />; otherwise, <see langword="false" />. /// <paramref name="right" />; otherwise, <see langword="false" />.
/// </returns> /// </returns>
public static bool operator <(Line left, Line right) public static bool operator <(in Line left, in Line right)
{ {
return left.CompareTo(right) < 0; return left.CompareTo(right) < 0;
} }
@ -119,7 +119,7 @@ public readonly struct Line : IEquatable<Line>, IComparable<Line>, IComparable
/// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is greater than that of /// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is greater than that of
/// <paramref name="right" />; otherwise, <see langword="false" />. /// <paramref name="right" />; otherwise, <see langword="false" />.
/// </returns> /// </returns>
public static bool operator >(Line left, Line right) public static bool operator >(in Line left, in Line right)
{ {
return left.CompareTo(right) > 0; return left.CompareTo(right) > 0;
} }
@ -133,7 +133,7 @@ public readonly struct Line : IEquatable<Line>, IComparable<Line>, IComparable
/// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is less than or equal to that of /// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is less than or equal to that of
/// <paramref name="right" />; otherwise, <see langword="false" />. /// <paramref name="right" />; otherwise, <see langword="false" />.
/// </returns> /// </returns>
public static bool operator <=(Line left, Line right) public static bool operator <=(in Line left, in Line right)
{ {
return left.CompareTo(right) <= 0; return left.CompareTo(right) <= 0;
} }
@ -147,7 +147,7 @@ public readonly struct Line : IEquatable<Line>, IComparable<Line>, IComparable
/// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is greater than or equal to that of /// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is greater than or equal to that of
/// <paramref name="right" />; otherwise, <see langword="false" />. /// <paramref name="right" />; otherwise, <see langword="false" />.
/// </returns> /// </returns>
public static bool operator >=(Line left, Line right) public static bool operator >=(in Line left, in Line right)
{ {
return left.CompareTo(right) >= 0; return left.CompareTo(right) >= 0;
} }

View File

@ -38,7 +38,7 @@ public readonly struct Line3D : IEquatable<Line3D>, IComparable<Line3D>, ICompar
/// </summary> /// </summary>
/// <param name="start">The start point.</param> /// <param name="start">The start point.</param>
/// <param name="end">The end point.</param> /// <param name="end">The end point.</param>
public Line3D(Vector3 start, Vector3 end) public Line3D(in Vector3 start, in Vector3 end)
{ {
End = end; End = end;
Start = start; Start = start;
@ -75,12 +75,12 @@ public readonly struct Line3D : IEquatable<Line3D>, IComparable<Line3D>, ICompar
public Vector3 Start { get; } public Vector3 Start { get; }
/// <summary> /// <summary>
/// Returns a value indicating whether two instances of <see cref="Line3D" /> are not equal. /// Returns a value indicating whether two instances of <see cref="Line3D" /> are equal.
/// </summary> /// </summary>
/// <param name="left">The first instance.</param> /// <param name="left">The first instance.</param>
/// <param name="right">The second instance.</param> /// <param name="right">The second instance.</param>
/// <returns> /// <returns>
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise, /// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered equal; otherwise,
/// <see langword="false" />. /// <see langword="false" />.
/// </returns> /// </returns>
public static bool operator ==(Line3D left, Line3D right) public static bool operator ==(Line3D left, Line3D right)
@ -111,7 +111,7 @@ public readonly struct Line3D : IEquatable<Line3D>, IComparable<Line3D>, ICompar
/// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is less than that of /// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is less than that of
/// <paramref name="right" />; otherwise, <see langword="false" />. /// <paramref name="right" />; otherwise, <see langword="false" />.
/// </returns> /// </returns>
public static bool operator <(Line3D left, Line3D right) public static bool operator <(in Line3D left, in Line3D right)
{ {
return left.CompareTo(right) < 0; return left.CompareTo(right) < 0;
} }
@ -125,7 +125,7 @@ public readonly struct Line3D : IEquatable<Line3D>, IComparable<Line3D>, ICompar
/// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is greater than that of /// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is greater than that of
/// <paramref name="right" />; otherwise, <see langword="false" />. /// <paramref name="right" />; otherwise, <see langword="false" />.
/// </returns> /// </returns>
public static bool operator >(Line3D left, Line3D right) public static bool operator >(in Line3D left, in Line3D right)
{ {
return left.CompareTo(right) > 0; return left.CompareTo(right) > 0;
} }
@ -139,7 +139,7 @@ public readonly struct Line3D : IEquatable<Line3D>, IComparable<Line3D>, ICompar
/// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is less than or equal to that of /// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is less than or equal to that of
/// <paramref name="right" />; otherwise, <see langword="false" />. /// <paramref name="right" />; otherwise, <see langword="false" />.
/// </returns> /// </returns>
public static bool operator <=(Line3D left, Line3D right) public static bool operator <=(in Line3D left, in Line3D right)
{ {
return left.CompareTo(right) <= 0; return left.CompareTo(right) <= 0;
} }
@ -153,7 +153,7 @@ public readonly struct Line3D : IEquatable<Line3D>, IComparable<Line3D>, ICompar
/// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is greater than or equal to that of /// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is greater than or equal to that of
/// <paramref name="right" />; otherwise, <see langword="false" />. /// <paramref name="right" />; otherwise, <see langword="false" />.
/// </returns> /// </returns>
public static bool operator >=(Line3D left, Line3D right) public static bool operator >=(in Line3D left, in Line3D right)
{ {
return left.CompareTo(right) >= 0; return left.CompareTo(right) >= 0;
} }
@ -163,7 +163,7 @@ public readonly struct Line3D : IEquatable<Line3D>, IComparable<Line3D>, ICompar
/// </summary> /// </summary>
/// <param name="line">The line to convert.</param> /// <param name="line">The line to convert.</param>
/// <returns>The converted line.</returns> /// <returns>The converted line.</returns>
public static explicit operator Line(Line3D line) public static explicit operator Line(in Line3D line)
{ {
Vector3 start = line.Start; Vector3 start = line.Start;
Vector3 end = line.End; Vector3 end = line.End;
@ -175,7 +175,7 @@ public readonly struct Line3D : IEquatable<Line3D>, IComparable<Line3D>, ICompar
/// </summary> /// </summary>
/// <param name="line">The line to convert.</param> /// <param name="line">The line to convert.</param>
/// <returns>The converted line.</returns> /// <returns>The converted line.</returns>
public static explicit operator LineF(Line3D line) public static explicit operator LineF(in Line3D line)
{ {
Vector3 start = line.Start; Vector3 start = line.Start;
Vector3 end = line.End; Vector3 end = line.End;
@ -187,7 +187,7 @@ public readonly struct Line3D : IEquatable<Line3D>, IComparable<Line3D>, ICompar
/// </summary> /// </summary>
/// <param name="line">The line to convert.</param> /// <param name="line">The line to convert.</param>
/// <returns>The converted line.</returns> /// <returns>The converted line.</returns>
public static implicit operator Line3D(Line line) public static implicit operator Line3D(in Line line)
{ {
Point start = line.Start; Point start = line.Start;
Point end = line.End; Point end = line.End;
@ -199,7 +199,7 @@ public readonly struct Line3D : IEquatable<Line3D>, IComparable<Line3D>, ICompar
/// </summary> /// </summary>
/// <param name="line">The line to convert.</param> /// <param name="line">The line to convert.</param>
/// <returns>The converted line.</returns> /// <returns>The converted line.</returns>
public static implicit operator Line3D(LineF line) public static implicit operator Line3D(in LineF line)
{ {
PointF start = line.Start; PointF start = line.Start;
PointF end = line.End; PointF end = line.End;

View File

@ -81,15 +81,15 @@ public readonly struct LineF : IEquatable<LineF>, IComparable<LineF>, IComparabl
public PointF Start { get; } public PointF Start { get; }
/// <summary> /// <summary>
/// Returns a value indicating whether two instances of <see cref="LineF" /> are not equal. /// Returns a value indicating whether two instances of <see cref="LineF" /> are equal.
/// </summary> /// </summary>
/// <param name="left">The first instance.</param> /// <param name="left">The first instance.</param>
/// <param name="right">The second instance.</param> /// <param name="right">The second instance.</param>
/// <returns> /// <returns>
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise, /// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered equal; otherwise,
/// <see langword="false" />. /// <see langword="false" />.
/// </returns> /// </returns>
public static bool operator ==(LineF left, LineF right) public static bool operator ==(in LineF left, in LineF right)
{ {
return left.Equals(right); return left.Equals(right);
} }
@ -103,7 +103,7 @@ public readonly struct LineF : IEquatable<LineF>, IComparable<LineF>, IComparabl
/// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise, /// <see langword="true" /> if <paramref name="left" /> and <paramref name="right" /> are considered not equal; otherwise,
/// <see langword="false" />. /// <see langword="false" />.
/// </returns> /// </returns>
public static bool operator !=(LineF left, LineF right) public static bool operator !=(in LineF left, in LineF right)
{ {
return !left.Equals(right); return !left.Equals(right);
} }
@ -117,7 +117,7 @@ public readonly struct LineF : IEquatable<LineF>, IComparable<LineF>, IComparabl
/// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is less than that of /// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is less than that of
/// <paramref name="right" />; otherwise, <see langword="false" />. /// <paramref name="right" />; otherwise, <see langword="false" />.
/// </returns> /// </returns>
public static bool operator <(LineF left, LineF right) public static bool operator <(in LineF left, in LineF right)
{ {
return left.CompareTo(right) < 0; return left.CompareTo(right) < 0;
} }
@ -131,7 +131,7 @@ public readonly struct LineF : IEquatable<LineF>, IComparable<LineF>, IComparabl
/// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is greater than that of /// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is greater than that of
/// <paramref name="right" />; otherwise, <see langword="false" />. /// <paramref name="right" />; otherwise, <see langword="false" />.
/// </returns> /// </returns>
public static bool operator >(LineF left, LineF right) public static bool operator >(in LineF left, in LineF right)
{ {
return left.CompareTo(right) > 0; return left.CompareTo(right) > 0;
} }
@ -145,7 +145,7 @@ public readonly struct LineF : IEquatable<LineF>, IComparable<LineF>, IComparabl
/// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is less than or equal to that of /// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is less than or equal to that of
/// <paramref name="right" />; otherwise, <see langword="false" />. /// <paramref name="right" />; otherwise, <see langword="false" />.
/// </returns> /// </returns>
public static bool operator <=(LineF left, LineF right) public static bool operator <=(in LineF left, in LineF right)
{ {
return left.CompareTo(right) <= 0; return left.CompareTo(right) <= 0;
} }
@ -159,7 +159,7 @@ public readonly struct LineF : IEquatable<LineF>, IComparable<LineF>, IComparabl
/// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is greater than or equal to that of /// <see langword="true" /> if the <see cref="Length" /> of <paramref name="left" /> is greater than or equal to that of
/// <paramref name="right" />; otherwise, <see langword="false" />. /// <paramref name="right" />; otherwise, <see langword="false" />.
/// </returns> /// </returns>
public static bool operator >=(LineF left, LineF right) public static bool operator >=(in LineF left, in LineF right)
{ {
return left.CompareTo(right) >= 0; return left.CompareTo(right) >= 0;
} }
@ -169,7 +169,7 @@ public readonly struct LineF : IEquatable<LineF>, IComparable<LineF>, IComparabl
/// </summary> /// </summary>
/// <param name="line">The line to convert.</param> /// <param name="line">The line to convert.</param>
/// <returns>The converted line.</returns> /// <returns>The converted line.</returns>
public static explicit operator Line(LineF line) public static explicit operator Line(in LineF line)
{ {
PointF start = line.Start; PointF start = line.Start;
PointF end = line.End; PointF end = line.End;
@ -181,7 +181,7 @@ public readonly struct LineF : IEquatable<LineF>, IComparable<LineF>, IComparabl
/// </summary> /// </summary>
/// <param name="line">The line to convert.</param> /// <param name="line">The line to convert.</param>
/// <returns>The converted line.</returns> /// <returns>The converted line.</returns>
public static implicit operator LineF(Line line) public static implicit operator LineF(in Line line)
{ {
return new LineF(line.Start, line.End); return new LineF(line.Start, line.End);
} }