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