Skip to content

Commit

Permalink
Merge pull request #37 from xin9le/feature/omit-ROS-byte
Browse files Browse the repository at this point in the history
Remove unnecessary `ReadOnlySpan<byte>` overloads
  • Loading branch information
xin9le authored Sep 5, 2024
2 parents fab5b23 + e39c6d4 commit b479f40
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 126 deletions.
102 changes: 1 addition & 101 deletions src/libs/FastEnum.Core/Internals/UnderlyingOperation.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <auto-generated>
// <auto-generated>
// This .cs file is generated by T4 template. Don't change it. Change the .tt file instead.
// </auto-generated>
#nullable enable
Expand Down Expand Up @@ -117,34 +117,6 @@ public static bool TryParseValue(ReadOnlySpan<char> text, out T result)
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryParseValue(ReadOnlySpan<byte> text, out T result)
{
switch (EnumInfo<T>.s_typeCode)
{
case TypeCode.SByte:
return SByteOperation.TryParseValue(text, out result);
case TypeCode.Byte:
return ByteOperation.TryParseValue(text, out result);
case TypeCode.Int16:
return Int16Operation.TryParseValue(text, out result);
case TypeCode.UInt16:
return UInt16Operation.TryParseValue(text, out result);
case TypeCode.Int32:
return Int32Operation.TryParseValue(text, out result);
case TypeCode.UInt32:
return UInt32Operation.TryParseValue(text, out result);
case TypeCode.Int64:
return Int64Operation.TryParseValue(text, out result);
case TypeCode.UInt64:
return UInt64Operation.TryParseValue(text, out result);
default:
result = default;
return false;
}
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetMember(T value, [NotNullWhen(true)] out Member<T>? result)
{
Expand Down Expand Up @@ -232,15 +204,6 @@ public static bool TryParseValue(ReadOnlySpan<char> text, out T result)
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryParseValue(ReadOnlySpan<byte> text, out T result)
{
Unsafe.SkipInit(out result);
ref var x = ref Unsafe.As<T, sbyte>(ref result);
return sbyte.TryParse(text, CultureInfo.InvariantCulture, out x);
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetMember(T value, [NotNullWhen(true)] out Member<T>? result)
{
Expand Down Expand Up @@ -338,15 +301,6 @@ public static bool TryParseValue(ReadOnlySpan<char> text, out T result)
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryParseValue(ReadOnlySpan<byte> text, out T result)
{
Unsafe.SkipInit(out result);
ref var x = ref Unsafe.As<T, byte>(ref result);
return byte.TryParse(text, CultureInfo.InvariantCulture, out x);
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetMember(T value, [NotNullWhen(true)] out Member<T>? result)
{
Expand Down Expand Up @@ -444,15 +398,6 @@ public static bool TryParseValue(ReadOnlySpan<char> text, out T result)
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryParseValue(ReadOnlySpan<byte> text, out T result)
{
Unsafe.SkipInit(out result);
ref var x = ref Unsafe.As<T, short>(ref result);
return short.TryParse(text, CultureInfo.InvariantCulture, out x);
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetMember(T value, [NotNullWhen(true)] out Member<T>? result)
{
Expand Down Expand Up @@ -550,15 +495,6 @@ public static bool TryParseValue(ReadOnlySpan<char> text, out T result)
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryParseValue(ReadOnlySpan<byte> text, out T result)
{
Unsafe.SkipInit(out result);
ref var x = ref Unsafe.As<T, ushort>(ref result);
return ushort.TryParse(text, CultureInfo.InvariantCulture, out x);
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetMember(T value, [NotNullWhen(true)] out Member<T>? result)
{
Expand Down Expand Up @@ -656,15 +592,6 @@ public static bool TryParseValue(ReadOnlySpan<char> text, out T result)
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryParseValue(ReadOnlySpan<byte> text, out T result)
{
Unsafe.SkipInit(out result);
ref var x = ref Unsafe.As<T, int>(ref result);
return int.TryParse(text, CultureInfo.InvariantCulture, out x);
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetMember(T value, [NotNullWhen(true)] out Member<T>? result)
{
Expand Down Expand Up @@ -762,15 +689,6 @@ public static bool TryParseValue(ReadOnlySpan<char> text, out T result)
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryParseValue(ReadOnlySpan<byte> text, out T result)
{
Unsafe.SkipInit(out result);
ref var x = ref Unsafe.As<T, uint>(ref result);
return uint.TryParse(text, CultureInfo.InvariantCulture, out x);
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetMember(T value, [NotNullWhen(true)] out Member<T>? result)
{
Expand Down Expand Up @@ -868,15 +786,6 @@ public static bool TryParseValue(ReadOnlySpan<char> text, out T result)
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryParseValue(ReadOnlySpan<byte> text, out T result)
{
Unsafe.SkipInit(out result);
ref var x = ref Unsafe.As<T, long>(ref result);
return long.TryParse(text, CultureInfo.InvariantCulture, out x);
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetMember(T value, [NotNullWhen(true)] out Member<T>? result)
{
Expand Down Expand Up @@ -974,15 +883,6 @@ public static bool TryParseValue(ReadOnlySpan<char> text, out T result)
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryParseValue(ReadOnlySpan<byte> text, out T result)
{
Unsafe.SkipInit(out result);
ref var x = ref Unsafe.As<T, ulong>(ref result);
return ulong.TryParse(text, CultureInfo.InvariantCulture, out x);
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetMember(T value, [NotNullWhen(true)] out Member<T>? result)
{
Expand Down
25 changes: 0 additions & 25 deletions src/libs/FastEnum.Core/Internals/UnderlyingOperation.tt
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,6 @@ internal static class UnderlyingOperation<T>
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryParseValue(ReadOnlySpan<byte> text, out T result)
{
switch (EnumInfo<T>.s_typeCode)
{
<# foreach (var x in parameters) { #>
case TypeCode.<#= x.TypeName #>:
return <#= x.TypeName #>Operation.TryParseValue(text, out result);
<# } #>
default:
result = default;
return false;
}
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetMember(T value, [NotNullWhen(true)] out Member<T>? result)
{
Expand Down Expand Up @@ -186,15 +170,6 @@ internal static class UnderlyingOperation<T>
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryParseValue(ReadOnlySpan<byte> text, out T result)
{
Unsafe.SkipInit(out result);
ref var x = ref Unsafe.As<T, <#= x.CompatibleName #>>(ref result);
return <#= x.CompatibleName #>.TryParse(text, CultureInfo.InvariantCulture, out x);
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetMember(T value, [NotNullWhen(true)] out Member<T>? result)
{
Expand Down

0 comments on commit b479f40

Please sign in to comment.