mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 17:38:47 +00:00
Compare commits
3 Commits
b843d155f6
...
bd823ba818
Author | SHA1 | Date | |
---|---|---|---|
bd823ba818 | |||
cfe70a7923 | |||
799e635577 |
@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
BigEndian/LittleEndian methods.
|
BigEndian/LittleEndian methods.
|
||||||
- X10D: `Stream.GetHash<>` and `Stream.TryWriteHash<>` now throw ArgumentException in lieu of
|
- X10D: `Stream.GetHash<>` and `Stream.TryWriteHash<>` now throw ArgumentException in lieu of
|
||||||
TypeInitializationException.
|
TypeInitializationException.
|
||||||
|
- X10D: `char.IsEmoji` no longer allocates for .NET 7.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ public static class DecimalExtensions
|
|||||||
private static void GetBits(decimal value, Span<int> destination)
|
private static void GetBits(decimal value, Span<int> destination)
|
||||||
{
|
{
|
||||||
#if NET5_0_OR_GREATER
|
#if NET5_0_OR_GREATER
|
||||||
decimal.GetBits(value, destination);
|
_ = decimal.GetBits(value, destination);
|
||||||
#else
|
#else
|
||||||
Span<byte> buffer = stackalloc byte[16];
|
Span<byte> buffer = stackalloc byte[16];
|
||||||
MemoryMarshal.Write(buffer, ref value);
|
MemoryMarshal.Write(buffer, ref value);
|
||||||
@ -101,6 +102,7 @@ public static class DecimalExtensions
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Conditional("NET5_0_OR_GREATER")]
|
||||||
private static void WriteBits(Span<int> destination, Span<byte> buffer)
|
private static void WriteBits(Span<int> destination, Span<byte> buffer)
|
||||||
{
|
{
|
||||||
var flags = MemoryMarshal.Read<int>(buffer[..4]);
|
var flags = MemoryMarshal.Read<int>(buffer[..4]);
|
||||||
|
@ -18,7 +18,13 @@ public static class CharExtensions
|
|||||||
[MethodImpl(CompilerResources.MethodImplOptions)]
|
[MethodImpl(CompilerResources.MethodImplOptions)]
|
||||||
public static bool IsEmoji(this char value)
|
public static bool IsEmoji(this char value)
|
||||||
{
|
{
|
||||||
return value.ToString().IsEmoji();
|
#if NET7_0_OR_GREATER
|
||||||
|
Span<char> chars = stackalloc char[1];
|
||||||
|
chars[0] = value;
|
||||||
|
return EmojiRegex.Value.IsMatch(chars);
|
||||||
|
#else
|
||||||
|
return EmojiRegex.Value.IsMatch(value.ToString());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user