Skip to content

Commit

Permalink
Micro optimization and package updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackburn29 committed Aug 12, 2024
1 parent 3c58858 commit 275a452
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/Fragment.NetSlum.Core/Fragment.NetSlum.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<Aliases>IPNetwork2</Aliases>
</PackageReference>
<PackageReference Include="Mediator.Abstractions" Version="2.1.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>

Expand Down
15 changes: 7 additions & 8 deletions src/Fragment.NetSlum.Networking/Objects/FragmentMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ public class FragmentMessage

public byte[] ToArray()
{
var length = sizeof(ushort) + Length;
var buffer = length <= 8192 ? stackalloc byte[length] : new byte[length];
const int dataOffset = 4;

var buffer = new byte[sizeof(ushort) + Length];
var span = new Span<byte>(buffer);
var dataOffset = 4;

BinaryPrimitives.WriteUInt16BigEndian(span[..2], Length);
BinaryPrimitives.WriteUInt16BigEndian(span[2..4], (ushort)MessageType);
BinaryPrimitives.WriteUInt16BigEndian(buffer[..2], Length);
BinaryPrimitives.WriteUInt16BigEndian(buffer[2..4], (ushort)MessageType);

// If the data of this message is already encrypted, it is assumed that the checksum was already appended since it needs to be
// included in the encrypted payload
Expand All @@ -40,9 +39,9 @@ public byte[] ToArray()
//dataOffset += 2;
}

Data.Span.CopyTo(span[dataOffset..]);
Data.Span.CopyTo(buffer[dataOffset..]);

return buffer;
return buffer.ToArray();
}

public override string ToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
namespace Fragment.NetSlum.Networking.Packets.Request.AreaServer;

[FragmentPacket(MessageType.Data, OpCodes.Data_AreaServerPublishRequest)]
public class AreaServerPublshRequest :BaseRequest
public class AreaServerPublishRequest :BaseRequest
{
private readonly ILogger<AreaServerPublshRequest> _logger;
private readonly ILogger<AreaServerPublishRequest> _logger;

public AreaServerPublshRequest(ILogger<AreaServerPublshRequest> logger)
public AreaServerPublishRequest(ILogger<AreaServerPublishRequest> logger)
{
_logger = logger;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Fragment.NetSlum.Server/Fragment.NetSlum.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@
<PackageReference Include="AspNetCore.HealthChecks.System" Version="8.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.1" />
<PackageReference Include="Haukcode.HighResolutionTimer" Version="1.1.0" />
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.9.1" />
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.10.0" />
<PackageReference Include="Mediator.SourceGenerator" Version="2.1.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.7" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="NSwag.AspNetCore" Version="14.0.8" />
<PackageReference Include="NSwag.AspNetCore" Version="14.1.0" />
<PackageReference Include="Riok.Mapperly" Version="3.6.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Serilog" Version="4.0.1" />
</ItemGroup>

</Project>

0 comments on commit 275a452

Please sign in to comment.