-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use more spans in System.Reflection.Metadata
et. al.
#76574
Conversation
Tagging subscribers to this area: @dotnet/area-system-reflection-metadata Issue DetailsThis PR among other things changes the buffer code of
|
...braries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/BlobUtilities.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/PEReader.cs
Show resolved
Hide resolved
...em.Reflection.Metadata/src/System/Reflection/Internal/Utilities/ImmutableByteArrayInterop.cs
Outdated
Show resolved
Hide resolved
...braries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/BlobUtilities.cs
Outdated
Show resolved
Hide resolved
...braries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/BlobUtilities.cs
Outdated
Show resolved
Hide resolved
...braries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/BlobUtilities.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobBuilder.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobBuilder.cs
Show resolved
Hide resolved
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobContentId.cs
Outdated
Show resolved
Hide resolved
} | ||
Unsafe.WriteUnaligned(ref buffer[start], value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: You could tidy this (and the others like it) up to just be:
public static void WriteUInt16(this byte[] buffer, int start, ushort value) =>
Unsafe.WriteUnaligned(ref buffer[start], BitConverter.IsLittleEndian ? BinaryPrimitives.ReverseEndianness(value) : value);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobBuilder.cs
Show resolved
Hide resolved
Are there any remaining CI issues? There were some Mono build failures, but I suspect infrastructure and just re-ran those. |
@teo-tsirpanis can you rebase to the latest? There are these build errors that have already recently been fixed (see this PR):
|
Code quality increases.
It prevents the JIT from looking into the method's body, realizing it's a throw helper, and doing what's best (such as considering it cold).
…UnderlyingArray`.
0232f77
to
d466b38
Compare
Done @steveharter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
This PR among other things changes the buffer code of
System.Reflection.Metadata
so that it uses spans and framework methods that are more optimized, and reduces pinning and unsafely converting between immutable and mutable arrays.