Skip to content

Commit d90c4f5

Browse files
authored
Avoid int[] allocation in ResourceReader when reading a decimal (dotnet#60408)
1 parent 9551e8a commit d90c4f5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,11 @@ private unsafe string AllocateStringForNameIndex(int index, out int dataOffset)
575575
return new TimeSpan(_store.ReadInt64());
576576
else if (type == typeof(decimal))
577577
{
578+
#if RESOURCES_EXTENSIONS
578579
int[] bits = new int[4];
580+
#else
581+
Span<int> bits = stackalloc int[4];
582+
#endif
579583
for (int i = 0; i < bits.Length; i++)
580584
bits[i] = _store.ReadInt32();
581585
return new decimal(bits);

0 commit comments

Comments
 (0)