DalamudAssetManager: avoid locks and lookups (#2015)

* Made DalamudAsset-to-something tables into arrays from dictionaries.
  Number of items in the DalamudAsset enum aren't many, and the numbers
  are small enough that implementing lookup tables as arrays aren't
  wasting much memory space.
* Removed locking from asset accessors, while still guaranteeing that
  the load operation happens only once per asset.
* ISharedImmediateTexture: made it not even access assets if textures
  are available.
This commit is contained in:
srkizer 2024-08-25 22:06:21 +09:00 committed by GitHub
parent 981387504b
commit 8822810229
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 168 additions and 145 deletions

View file

@ -171,17 +171,14 @@ internal abstract class SharedImmediateTexture
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public IDalamudTextureWrap GetWrapOrEmpty() => this.GetWrapOrDefault(Service<DalamudAssetManager>.Get().Empty4X4);
public IDalamudTextureWrap GetWrapOrEmpty() =>
this.TryGetWrap(out var texture, out _) ? texture : Service<DalamudAssetManager>.Get().Empty4X4;
/// <inheritdoc/>
[return: NotNullIfNotNull(nameof(defaultWrap))]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public IDalamudTextureWrap? GetWrapOrDefault(IDalamudTextureWrap? defaultWrap)
{
if (!this.TryGetWrap(out var texture, out _))
texture = null;
return texture ?? defaultWrap;
}
public IDalamudTextureWrap? GetWrapOrDefault(IDalamudTextureWrap? defaultWrap) =>
this.TryGetWrap(out var texture, out _) ? texture : defaultWrap;
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]