faster number check

This commit is contained in:
Qrakhen 2025-11-09 20:04:34 +01:00
parent 0b350ff4ec
commit dc94c16b03
4 changed files with 10 additions and 5 deletions

View File

@ -559,6 +559,7 @@ public class Digester : ISteppable<Token>
internal long IdentifierConstant(string? name) internal long IdentifierConstant(string? name)
{ {
_logger.Method(name);
return MakeConstant(String.Make(name ?? return MakeConstant(String.Make(name ??
throw new TokenException("Empty string value for identifier detected", _reader, Current))); throw new TokenException("Empty string value for identifier detected", _reader, Current)));
} }

View File

@ -1,6 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Xml.XPath;
namespace Qrakhen.Qamp.Core.Logging; namespace Qrakhen.Qamp.Core.Logging;

View File

@ -47,7 +47,7 @@ public readonly struct Value : IValue, ISerialize<Value>, IDebug<string>
public T ValueType => Type; public T ValueType => Type;
public bool IsNumber => IsSigned || IsUnsigned || IsDecimal; public bool IsNumber => Type <= T.Decimal;
public bool IsSigned => Is(T.Signed); public bool IsSigned => Is(T.Signed);
public bool IsUnsigned => Is(T.Unsigned); public bool IsUnsigned => Is(T.Unsigned);
public bool IsDecimal => Is(T.Decimal); public bool IsDecimal => Is(T.Decimal);
@ -93,6 +93,11 @@ public readonly struct Value : IValue, ISerialize<Value>, IDebug<string>
return new Value(); return new Value();
} }
public void __gcMark()
{
if (IsObj && Ptr.Value != null) { }
}
public override bool Equals([NotNullWhen(true)] object? obj) public override bool Equals([NotNullWhen(true)] object? obj)
{ {
return obj switch { return obj switch {

View File

@ -11,8 +11,8 @@ public enum ValueType
Void = 0x0000, Void = 0x0000,
Unsigned = 0x0001, Unsigned = 0x0001,
Signed = 0x0002, Signed = 0x0002,
Char = 0x0004, Decimal = 0x0004,
Decimal = 0x0008, Char = 0x0008,
Bool = 0x0010, Bool = 0x0010,
Number = Unsigned | Signed | Decimal, Number = Unsigned | Signed | Decimal,