Skip locals init.

This commit is contained in:
Ottermandias 2024-03-16 16:21:23 +01:00
parent 4fc763c9aa
commit 50f81cc889
4 changed files with 14 additions and 10 deletions

View file

@ -62,6 +62,7 @@ public sealed unsafe class LiveColorTablePreviewer : LiveMaterialPreviewerBase
_updatePending = true;
}
[SkipLocalsInit]
private void OnFrameworkUpdate(IFramework _)
{
if (!_updatePending)

View file

@ -89,6 +89,7 @@ internal partial record ResolveContext
};
}
[SkipLocalsInit]
private unsafe Utf8GamePath ResolveEquipmentMaterialPath(Utf8GamePath modelPath, ResourceHandle* imc, byte* mtrlFileName)
{
var variant = ResolveMaterialVariant(imc, Equipment.Variant);
@ -100,6 +101,7 @@ internal partial record ResolveContext
return Utf8GamePath.FromSpan(pathBuffer, out var path) ? path.Clone() : Utf8GamePath.Empty;
}
[SkipLocalsInit]
private unsafe Utf8GamePath ResolveWeaponMaterialPath(Utf8GamePath modelPath, ResourceHandle* imc, byte* mtrlFileName)
{
var setIdHigh = Equipment.Set.Id / 100;
@ -168,7 +170,7 @@ internal partial record ResolveContext
{
var modelPosition = modelPath.IndexOf("/model/"u8);
if (modelPosition < 0)
return Span<byte>.Empty;
return [];
var baseDirectory = modelPath[..modelPosition];

View file

@ -54,6 +54,7 @@ internal unsafe partial record ResolveContext(
return GetOrCreateNode(ResourceType.Shpk, (nint)resourceHandle->ShaderPackage, &resourceHandle->ResourceHandle, path);
}
[SkipLocalsInit]
private ResourceNode? CreateNodeFromTex(TextureResourceHandle* resourceHandle, ByteString gamePath, bool dx11)
{
if (resourceHandle == null)

View file

@ -7,8 +7,8 @@ namespace Penumbra.Mods.Editor;
public class DuplicateManager(ModManager modManager, SaveService saveService, Configuration config)
{
private readonly SHA256 _hasher = SHA256.Create();
private readonly List<(FullPath[] Paths, long Size, byte[] Hash)> _duplicates = [];
private readonly SHA256 _hasher = SHA256.Create();
private readonly List<(FullPath[] Paths, long Size, byte[] Hash)> _duplicates = [];
public IReadOnlyList<(FullPath[] Paths, long Size, byte[] Hash)> Duplicates
=> _duplicates;
@ -164,17 +164,17 @@ public class DuplicateManager(ModManager modManager, SaveService saveService, Co
}
/// <summary> Check if two files are identical on a binary level. Returns true if they are identical. </summary>
[SkipLocalsInit]
public static unsafe bool CompareFilesDirectly(FullPath f1, FullPath f2)
{
const int size = 256;
if (!f1.Exists || !f2.Exists)
return false;
using var s1 = File.OpenRead(f1.FullName);
using var s2 = File.OpenRead(f2.FullName);
var buffer1 = stackalloc byte[256];
var buffer2 = stackalloc byte[256];
var span1 = new Span<byte>(buffer1, 256);
var span2 = new Span<byte>(buffer2, 256);
using var s1 = File.OpenRead(f1.FullName);
using var s2 = File.OpenRead(f2.FullName);
Span<byte> span1 = stackalloc byte[size];
Span<byte> span2 = stackalloc byte[size];
while (true)
{
@ -186,7 +186,7 @@ public class DuplicateManager(ModManager modManager, SaveService saveService, Co
if (!span1[..bytes1].SequenceEqual(span2[..bytes2]))
return false;
if (bytes1 < 256)
if (bytes1 < size)
return true;
}
}