We have a few places in the code where we compare locals of type uint against int.MaxValue.
|
if ((uint)newSize > int.MaxValue) |
|
{ |
|
newSize = currentLength + sizeHint; |
|
if ((uint)newSize > int.MaxValue) |
|
using (SafeEvpPKeyCtxHandle ctx = Interop.Crypto.EvpPKeyCtxCreate(ourKey, theirKey, out uint secretLengthU)) |
|
{ |
|
if (ctx == null || ctx.IsInvalid || secretLengthU == 0 || secretLengthU > int.MaxValue) |
|
if (Utf8Parser.TryParse(data, out uint value, out int consumed) && |
|
value <= int.MaxValue && |
|
consumed == data.Length) |
|
uint offset = _reader.FieldLayoutTable.GetOffset(layoutRowId); |
|
if (offset > int.MaxValue) |
There's an opportunity for a few bytes of codegen savings across these methods if the JIT treat these calls as (int)value < 0 or (int)value >= 0 instead of performing a direct comparison against the constant value 0x7FFFFFFF.
category:cq
theme:codegen
skill-level:intermediate
cost:small
We have a few places in the code where we compare locals of type
uintagainstint.MaxValue.runtime/src/libraries/Common/src/System/Buffers/ArrayBufferWriter.cs
Lines 180 to 183 in a0c3324
runtime/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.Derive.cs
Lines 149 to 151 in a0c3324
runtime/src/libraries/Common/src/System/Security/Cryptography/Asn1Reader/AsnReader.cs
Lines 417 to 419 in a0c3324
runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/FieldDefinition.cs
Lines 119 to 120 in a0c3324
There's an opportunity for a few bytes of codegen savings across these methods if the JIT treat these calls as
(int)value < 0or(int)value >= 0instead of performing a direct comparison against the constant value0x7FFFFFFF.category:cq
theme:codegen
skill-level:intermediate
cost:small