-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
We have a few places in the code where we compare locals of type uint against int.MaxValue.
runtime/src/libraries/Common/src/System/Buffers/ArrayBufferWriter.cs
Lines 180 to 183 in a0c3324
| if ((uint)newSize > int.MaxValue) | |
| { | |
| newSize = currentLength + sizeHint; | |
| if ((uint)newSize > int.MaxValue) |
runtime/src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.Derive.cs
Lines 149 to 151 in a0c3324
| using (SafeEvpPKeyCtxHandle ctx = Interop.Crypto.EvpPKeyCtxCreate(ourKey, theirKey, out uint secretLengthU)) | |
| { | |
| if (ctx == null || ctx.IsInvalid || secretLengthU == 0 || secretLengthU > int.MaxValue) |
runtime/src/libraries/Common/src/System/Security/Cryptography/Asn1Reader/AsnReader.cs
Lines 417 to 419 in a0c3324
| if (Utf8Parser.TryParse(data, out uint value, out int consumed) && | |
| value <= int.MaxValue && | |
| consumed == data.Length) |
Lines 119 to 120 in a0c3324
| 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