Skip to content

Commit

Permalink
Fix this PR with Imports & Dead Code Removal
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Nov 27, 2023
1 parent 130265c commit dc63e98
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 259 deletions.
65 changes: 0 additions & 65 deletions benchmarks/NexusMods.Benchmarks/Benchmarks/ChangeCase.cs

This file was deleted.

This file was deleted.

122 changes: 0 additions & 122 deletions benchmarks/NexusMods.Benchmarks/Benchmarks/VectorisedStringHash.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.Json.Serialization;
using JetBrains.Annotations;
using NexusMods.Paths.Extensions;
using Reloaded.Memory.Extensions;

namespace NexusMods.Games.StardewValley.Models;

Expand Down
13 changes: 8 additions & 5 deletions src/NexusMods.DataModel/ChunkedStreams/ChunkedStream.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Buffers;
using NexusMods.Paths.Extensions;
using Reloaded.Memory.Extensions;

namespace NexusMods.DataModel.ChunkedStreams;

Expand Down Expand Up @@ -28,9 +29,7 @@ public ChunkedStream(T source, int capacity = 16)
}

/// <inheritdoc />
public override void Flush()
{
}
public override void Flush() { }


/// <inheritdoc />
Expand All @@ -55,6 +54,7 @@ public override int Read(byte[] buffer, int offset, int count)
toRead = Math.Min(toRead, (int)lastChunkExtraSize);
}
}

chunk.Slice((int)chunkOffset, toRead)
.Span
.CopyTo(buffer.AsSpan(offset, toRead));
Expand All @@ -64,7 +64,8 @@ public override int Read(byte[] buffer, int offset, int count)


/// <inheritdoc />
public override async ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = new CancellationToken())
public override async ValueTask<int> ReadAsync(Memory<byte> buffer,
CancellationToken cancellationToken = new CancellationToken())
{
if (_position >= _source.Size.Value)
{
Expand All @@ -87,12 +88,12 @@ public override int Read(byte[] buffer, int offset, int count)
toRead = Math.Min(toRead, (int)lastChunkExtraSize);
}
}

chunk.Slice((int)chunkOffset, toRead)
.Span
.CopyTo(buffer.Span.SliceFast(0, toRead));
_position += (ulong)toRead;
return toRead;

}

private async ValueTask<Memory<byte>> GetChunkAsync(ulong index, CancellationToken token)
Expand All @@ -101,6 +102,7 @@ private async ValueTask<Memory<byte>> GetChunkAsync(ulong index, CancellationTok
{
return memory!.Memory;
}

var memoryOwner = _pool.Rent((int)_source.ChunkSize.Value);
await _source.ReadChunkAsync(memoryOwner.Memory, index, token);
_cache.Add(index, memoryOwner);
Expand All @@ -113,6 +115,7 @@ private Memory<byte> GetChunk(ulong index)
{
return memory!.Memory;
}

var memoryOwner = _pool.Rent((int)_source.ChunkSize.Value);
_source.ReadChunk(memoryOwner.Memory.Span, index);
_cache.Add(index, memoryOwner);
Expand Down
3 changes: 3 additions & 0 deletions src/NexusMods.DataModel/ChunkedStreams/LightweightLRUCache.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NexusMods.Paths.Extensions;
using Reloaded.Memory.Extensions;

namespace NexusMods.DataModel.ChunkedStreams;

Expand Down Expand Up @@ -45,6 +46,7 @@ public bool TryGet(TK key, out TV? value)
Touch(index);
return true;
}

value = default;
return false;
}
Expand Down Expand Up @@ -78,6 +80,7 @@ private readonly int Find(TK key)
{
if (_keys[i].Equals(key)) return i;
}

return -1;
}

Expand Down
1 change: 1 addition & 0 deletions src/NexusMods.DataModel/Loadouts/Cursors/ModCursor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NexusMods.DataModel.Interprocess;
using NexusMods.Paths.Extensions;
using Reloaded.Memory.Extensions;

namespace NexusMods.DataModel.Loadouts.Cursors;

Expand Down
1 change: 1 addition & 0 deletions src/NexusMods.DataModel/Loadouts/DiskStateRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using NexusMods.DataModel.Abstractions;
using NexusMods.DataModel.LoadoutSynchronizer;
using NexusMods.Paths.Extensions;
using Reloaded.Memory.Extensions;

namespace NexusMods.DataModel.Loadouts;

Expand Down
Loading

0 comments on commit dc63e98

Please sign in to comment.