Browse Source

Omit types when infererable from the left or right hand sides

af/merge-core
Jason Nelson 8 years ago
parent
commit
7194abe293
  1. 2
      src/ImageSharp/ColorSpaces/CieLab.cs
  2. 28
      src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs
  3. 2
      src/ImageSharp/PixelFormats/Argb32.cs
  4. 6
      src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs
  5. 4
      src/ImageSharp/PixelFormats/HalfTypeHelper.cs
  6. 2
      src/ImageSharp/PixelFormats/NamedColors{TPixel}.cs
  7. 4
      src/ImageSharp/Primitives/LongRational.cs
  8. 11
      src/ImageSharp/Primitives/SignedRational.cs

2
src/ImageSharp/ColorSpaces/CieLab.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
/// <summary>
/// Represents a <see cref="CieLab"/> that has L, A, B values set to zero.
/// </summary>
public static readonly CieLab Empty = default(CieLab);
public static readonly CieLab Empty = default;
/// <summary>
/// The backing vector for SIMD support.

28
src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs

@ -33,20 +33,12 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
/// <summary>
/// Gets the thumbnail length in the byte stream
/// </summary>
public uint ThumbnailLength
{
get;
private set;
}
public uint ThumbnailLength { get; private set; }
/// <summary>
/// Gets the thumbnail offset position in the byte stream
/// </summary>
public uint ThumbnailOffset
{
get;
private set;
}
public uint ThumbnailOffset { get; private set; }
/// <summary>
/// Gets the remaining length.
@ -124,8 +116,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
int dataTypeSize = (int)ExifValue.GetSize(dataType);
int length = data.Length / dataTypeSize;
TDataType[] result = new TDataType[length];
byte[] buffer = new byte[dataTypeSize];
var result = new TDataType[length];
var buffer = new byte[dataTypeSize];
for (int i = 0; i < length; i++)
{
@ -423,7 +415,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
{
if (!this.ValidateArray(data, 8))
{
return default(double);
return default;
}
return BitConverter.ToDouble(data, 0);
@ -433,7 +425,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
{
if (!this.ValidateArray(data, 4))
{
return default(uint);
return default;
}
return BitConverter.ToUInt32(data, 0);
@ -443,7 +435,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
{
if (!this.ValidateArray(data, 2))
{
return default(ushort);
return default;
}
return BitConverter.ToUInt16(data, 0);
@ -453,7 +445,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
{
if (!this.ValidateArray(data, 4))
{
return default(float);
return default;
}
return BitConverter.ToSingle(data, 0);
@ -491,7 +483,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
{
if (!this.ValidateArray(data, 8, 4))
{
return default(SignedRational);
return default;
}
int numerator = BitConverter.ToInt32(data, 0);
@ -504,7 +496,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif
{
if (!this.ValidateArray(data, 2))
{
return default(short);
return default;
}
return BitConverter.ToInt16(data, 0);

2
src/ImageSharp/PixelFormats/Argb32.cs

@ -347,7 +347,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint Pack(ref Vector3 vector)
{
Vector4 value = new Vector4(vector, 1);
var value = new Vector4(vector, 1);
return Pack(ref value);
}

6
src/ImageSharp/PixelFormats/ColorBuilder{TPixel}.cs

@ -32,8 +32,8 @@ namespace SixLabors.ImageSharp.PixelFormats
throw new ArgumentException("Hexadecimal string is not in the correct format.", nameof(hex));
}
TPixel result = default(TPixel);
Rgba32 rgba = new Rgba32(
TPixel result = default;
var rgba = new Rgba32(
(byte)(packedValue >> 24),
(byte)(packedValue >> 16),
(byte)(packedValue >> 8),
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <returns>Returns a <typeparamref name="TPixel"/> that represents the color defined by the provided RGBA values.</returns>
public static TPixel FromRGBA(byte red, byte green, byte blue, byte alpha)
{
TPixel color = default(TPixel);
TPixel color = default;
color.PackFromRgba32(new Rgba32(red, green, blue, alpha));
return color;
}

4
src/ImageSharp/PixelFormats/HalfTypeHelper.cs

@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static ushort Pack(float value)
{
Uif uif = new Uif { F = value };
var uif = new Uif { F = value };
return Pack(uif.I);
}
@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.PixelFormats
result = ((((uint)value & 0x8000) << 16) | ((((((uint)value >> 10) & 0x1f) - 15) + 127) << 23)) | (mantissa << 13);
}
Uif uif = new Uif { U = result };
var uif = new Uif { U = result };
return uif.F;
}

2
src/ImageSharp/PixelFormats/NamedColors{TPixel}.cs

@ -735,7 +735,7 @@ namespace SixLabors.ImageSharp.PixelFormats
private static TPixel[] GetWebSafePalette()
{
Rgba32[] constants = ColorConstants.WebSafeColors;
TPixel[] safe = new TPixel[constants.Length + 1];
var safe = new TPixel[constants.Length + 1];
Span<byte> constantsBytes = constants.AsSpan().NonPortableCast<Rgba32, byte>();
PixelOperations<TPixel>.Instance.PackFromRgba32Bytes(constantsBytes, safe, constants.Length);

4
src/ImageSharp/Primitives/LongRational.cs

@ -268,9 +268,9 @@ namespace SixLabors.ImageSharp.Primitives
return this.Numerator.ToString(provider);
}
StringBuilder sb = new StringBuilder();
var sb = new StringBuilder();
sb.Append(this.Numerator.ToString(provider));
sb.Append("/");
sb.Append('/');
sb.Append(this.Denominator.ToString(provider));
return sb.ToString();
}

11
src/ImageSharp/Primitives/SignedRational.cs

@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Primitives
/// <param name="bestPrecision">Whether to use the best possible precision when parsing the value.</param>
public SignedRational(double value, bool bestPrecision)
{
LongRational rational = new LongRational(value, bestPrecision);
var rational = new LongRational(value, bestPrecision);
this.Numerator = (int)rational.Numerator;
this.Denominator = (int)rational.Denominator;
@ -129,12 +129,7 @@ namespace SixLabors.ImageSharp.Primitives
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (obj is SignedRational)
{
return this.Equals((SignedRational)obj);
}
return false;
return obj is SignedRational other && Equals(other);
}
/// <inheritdoc/>
@ -149,7 +144,7 @@ namespace SixLabors.ImageSharp.Primitives
/// <inheritdoc/>
public override int GetHashCode()
{
LongRational self = new LongRational(this.Numerator, this.Denominator);
var self = new LongRational(this.Numerator, this.Denominator);
return self.GetHashCode();
}

Loading…
Cancel
Save