Skip to content

Commit 57a77e6

Browse files
committed
Iteration optimization in OutboxJob serialization and deserialization,
1 parent 192bda4 commit 57a77e6

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<OutputType>Exe</OutputType>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
12+
<PackageReference Include="xunit.v3" Version="3.2.2" />
13+
</ItemGroup>
14+
15+
</Project>

src/Hangfire.Community.Outbox.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.11.35327.3
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hangfire.Community.Outbox", "Hangfire.Community.Outbox\Hangfire.Community.Outbox.csproj", "{BADFAE74-E280-424D-B2C9-9736AC9D82DE}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hangfire.Community.Outbox.Tests", "Hangfire.Community.Outbox.Tests\Hangfire.Community.Outbox.Tests.csproj", "{8FE83711-A2F0-4FDB-983B-B5EECF8D7706}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{BADFAE74-E280-424D-B2C9-9736AC9D82DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{BADFAE74-E280-424D-B2C9-9736AC9D82DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{BADFAE74-E280-424D-B2C9-9736AC9D82DE}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{8FE83711-A2F0-4FDB-983B-B5EECF8D7706}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{8FE83711-A2F0-4FDB-983B-B5EECF8D7706}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{8FE83711-A2F0-4FDB-983B-B5EECF8D7706}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{8FE83711-A2F0-4FDB-983B-B5EECF8D7706}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

src/Hangfire.Community.Outbox/Entities/OutboxJob.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,18 @@ public IEnumerable<object> GetArguments()
166166

167167
var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(ArgumentValuesJson));
168168
var element = JsonElement.ParseValue(ref reader);
169-
var elements = element.EnumerateArray();
169+
var elements = element.EnumerateArray().ToArray();
170170

171-
for (int i = 0; i < elements.Count(); i++)
171+
for (var i = 0; i < elements.Length; i++)
172172
{
173-
if (types[i] == typeof(CancellationToken))
173+
var targetType = types[i];
174+
if (targetType == typeof(CancellationToken))
174175
{
175176
yield return CancellationToken.None;
176177
continue;
177178
}
178-
179-
yield return elements.ElementAt(i).Deserialize(types[i]);
179+
180+
yield return elements[i].Deserialize(targetType);
180181
}
181182
}
182183

0 commit comments

Comments
 (0)