Skip to content

Commit 821af80

Browse files
committed
Version 1.0.3: Added AggressiveInlining to Allocate methods.
1 parent fe16905 commit 821af80

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

UnmanagedMemoryUtils/UnmanagedMemoryUtils/ReadOnlyUnmanagedMemory.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace UnmanagedMemoryUtils
1919
/// </summary>
2020
/// <param name="length">The length of the memory range.</param>
2121
/// <returns>The unmanaged memory that points to the newly allocated memory.</returns>
22+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2223
public static ReadOnlyUnmanagedMemory AllocateFromHGlobal(int length)
2324
{
2425
return new ReadOnlyUnmanagedMemory(Marshal.AllocHGlobal(length), length);
@@ -29,6 +30,7 @@ public static ReadOnlyUnmanagedMemory AllocateFromHGlobal(int length)
2930
/// </summary>
3031
/// <param name="length">The length of the memory range.</param>
3132
/// <returns>The unmanaged memory that points to the newly allocated memory.</returns>
33+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3234
public static ReadOnlyUnmanagedMemory AllocateFromCoTaskMem(int length)
3335
{
3436
return new ReadOnlyUnmanagedMemory(Marshal.AllocCoTaskMem(length), length);
@@ -311,6 +313,7 @@ public override readonly int GetHashCode()
311313
/// </summary>
312314
/// <param name="length">The amount of items to store in this memory.</param>
313315
/// <returns>The unmanaged memory that points to the newly allocated memory.</returns>
316+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
314317
public static ReadOnlyUnmanagedMemory<T> AllocateFromHGlobal(int length)
315318
{
316319
return new ReadOnlyUnmanagedMemory<T>(Marshal.AllocHGlobal(length * TypeSize), length);
@@ -321,6 +324,7 @@ public static ReadOnlyUnmanagedMemory<T> AllocateFromHGlobal(int length)
321324
/// </summary>
322325
/// <param name="length">The amount of items to store in this memory.</param>
323326
/// <returns>The unmanaged memory that points to the newly allocated memory.</returns>
327+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
324328
public static ReadOnlyUnmanagedMemory<T> AllocateFromCoTaskMem(int length)
325329
{
326330
return new ReadOnlyUnmanagedMemory<T>(Marshal.AllocCoTaskMem(length * TypeSize), length);

UnmanagedMemoryUtils/UnmanagedMemoryUtils/UnmanagedMemory.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace UnmanagedMemoryUtils
1919
/// </summary>
2020
/// <param name="length">The length of the memory range.</param>
2121
/// <returns>The unmanaged memory that points to the newly allocated memory.</returns>
22+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2223
public static UnmanagedMemory AllocateFromHGlobal(int length)
2324
{
2425
return new UnmanagedMemory(Marshal.AllocHGlobal(length), length);
@@ -29,6 +30,7 @@ public static UnmanagedMemory AllocateFromHGlobal(int length)
2930
/// </summary>
3031
/// <param name="length">The length of the memory range.</param>
3132
/// <returns>The unmanaged memory that points to the newly allocated memory.</returns>
33+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3234
public static UnmanagedMemory AllocateFromCoTaskMem(int length)
3335
{
3436
return new UnmanagedMemory(Marshal.AllocCoTaskMem(length), length);
@@ -313,6 +315,7 @@ public override readonly int GetHashCode()
313315
/// </summary>
314316
/// <param name="length">The amount of items to store in this memory.</param>
315317
/// <returns>The unmanaged memory that points to the newly allocated memory.</returns>
318+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
316319
public static UnmanagedMemory<T> AllocateFromHGlobal(int length)
317320
{
318321
return new UnmanagedMemory<T>(Marshal.AllocHGlobal(length * TypeSize), length);
@@ -323,6 +326,7 @@ public static UnmanagedMemory<T> AllocateFromHGlobal(int length)
323326
/// </summary>
324327
/// <param name="length">The amount of items to store in this memory.</param>
325328
/// <returns>The unmanaged memory that points to the newly allocated memory.</returns>
329+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
326330
public static UnmanagedMemory<T> AllocateFromCoTaskMem(int length)
327331
{
328332
return new UnmanagedMemory<T>(Marshal.AllocCoTaskMem(length * TypeSize), length);

UnmanagedMemoryUtils/UnmanagedMemoryUtils/UnmanagedMemoryUtils.csproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
88
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
99
<Title>UnmanagedMemoryUtils</Title>
10-
<VersionPrefix>1.0.2</VersionPrefix>
10+
<VersionPrefix>1.0.3</VersionPrefix>
1111
<PackageReadmeFile>README.md</PackageReadmeFile>
1212
<Description>A .NET collection of utilities for working with unmanaged memory.
1313
Provides faster alternatives to Memory&lt;T&gt; and ReadOnlyMemory&lt;T&gt; in addition to accessing unmanaged string from managed code.</Description>
@@ -17,7 +17,13 @@ Provides faster alternatives to Memory&lt;T&gt; and ReadOnlyMemory&lt;T&gt; in a
1717
<PackageTags>.NET;C#</PackageTags>
1818
<Copyright>BSD-3-Clause license</Copyright>
1919
<PackageProjectUrl>https://github.com/Azengar/UnmanagedMemoryUtils</PackageProjectUrl>
20-
<PackageReleaseNotes>* Changed from `Unsafe.CopyBlock` to `Unsafe.CopyBlockUnaligned`</PackageReleaseNotes>
20+
<PackageReleaseNotes>Version 1.0.2
21+
22+
* Changed from `Unsafe.CopyBlock` to `Unsafe.CopyBlockUnaligned`.
23+
24+
Version 1.0.3
25+
26+
* Added Aggressive Inlining for Allocate methods.</PackageReleaseNotes>
2127
</PropertyGroup>
2228
<ItemGroup>
2329
<None Include="..\..\README.md" Pack="true" PackagePath="\" />

0 commit comments

Comments
 (0)