Remove unnecessary IsNull functions

This commit is contained in:
Haselnussbomber 2025-07-17 01:42:20 +02:00
parent 54ec64e159
commit 9956424c13
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
5 changed files with 17 additions and 31 deletions

View file

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Dalamud.Bindings.ImGui; using Dalamud.Bindings.ImGui;
@ -158,7 +158,7 @@ internal sealed class DelegateFontHandle : FontHandle
{ {
toolkitPreBuild.Font = default; toolkitPreBuild.Font = default;
k.CallOnBuildStepChange(toolkitPreBuild); k.CallOnBuildStepChange(toolkitPreBuild);
if (toolkitPreBuild.Font.IsNull()) if (toolkitPreBuild.Font.IsNull)
{ {
if (fontCountPrevious == fontsVector.Length) if (fontCountPrevious == fontsVector.Length)
{ {

View file

@ -116,7 +116,7 @@ internal sealed partial class FontAtlasFactory
foreach (var s in this.data.Substances) foreach (var s in this.data.Substances)
{ {
var f = s.GetFontPtr(fontHandle); var f = s.GetFontPtr(fontHandle);
if (!f.IsNull()) if (!f.IsNull)
return f; return f;
} }
@ -215,7 +215,7 @@ internal sealed partial class FontAtlasFactory
} }
catch catch
{ {
if (!font.IsNull()) if (!font.IsNull)
{ {
// Note that for both RemoveAt calls, corresponding destructors will be called. // Note that for both RemoveAt calls, corresponding destructors will be called.
@ -331,14 +331,14 @@ internal sealed partial class FontAtlasFactory
} }
} }
if (font.IsNull()) if (font.IsNull)
{ {
// fall back to AXIS fonts // fall back to AXIS fonts
font = this.AddGameGlyphs(new(GameFontFamily.Axis, sizePx), glyphRanges, default); font = this.AddGameGlyphs(new(GameFontFamily.Axis, sizePx), glyphRanges, default);
} }
this.AttachExtraGlyphsForDalamudLanguage(new() { SizePx = sizePx, MergeFont = font }); this.AttachExtraGlyphsForDalamudLanguage(new() { SizePx = sizePx, MergeFont = font });
if (this.Font.IsNull()) if (this.Font.IsNull)
this.Font = font; this.Font = font;
return font; return font;
} }
@ -413,9 +413,9 @@ internal sealed partial class FontAtlasFactory
int style = (int)DWRITE_FONT_STYLE.DWRITE_FONT_STYLE_NORMAL) int style = (int)DWRITE_FONT_STYLE.DWRITE_FONT_STYLE_NORMAL)
{ {
var targetFont = fontConfig.MergeFont; var targetFont = fontConfig.MergeFont;
if (targetFont.IsNull()) if (targetFont.IsNull)
targetFont = this.Font; targetFont = this.Font;
if (targetFont.IsNull()) if (targetFont.IsNull)
return; return;
// https://learn.microsoft.com/en-us/windows/apps/design/globalizing/loc-international-fonts // https://learn.microsoft.com/en-us/windows/apps/design/globalizing/loc-international-fonts
@ -556,9 +556,9 @@ internal sealed partial class FontAtlasFactory
public void AttachExtraGlyphsForDalamudLanguage(in SafeFontConfig fontConfig) public void AttachExtraGlyphsForDalamudLanguage(in SafeFontConfig fontConfig)
{ {
var targetFont = fontConfig.MergeFont; var targetFont = fontConfig.MergeFont;
if (targetFont.IsNull()) if (targetFont.IsNull)
targetFont = this.Font; targetFont = this.Font;
if (targetFont.IsNull()) if (targetFont.IsNull)
return; return;
var dalamudConfiguration = Service<DalamudConfiguration>.Get(); var dalamudConfiguration = Service<DalamudConfiguration>.Get();

View file

@ -182,7 +182,7 @@ internal abstract class FontHandle : IFontHandle
} }
var fontPtr = substance.GetFontPtr(this); var fontPtr = substance.GetFontPtr(this);
if (fontPtr.IsNull()) if (fontPtr.IsNull)
{ {
// The font for the requested handle is unavailable. Release the reference and try again. // The font for the requested handle is unavailable. Release the reference and try again.
substance.DataRoot.Release(); substance.DataRoot.Release();

View file

@ -1,4 +1,4 @@
using System.Buffers; using System.Buffers;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
@ -250,7 +250,7 @@ internal class GamePrebakedFontHandle : FontHandle
GameFontStyle style, GameFontStyle style,
ushort[]? glyphRanges = null) ushort[]? glyphRanges = null)
{ {
if (font.IsNull()) if (font.IsNull)
font = this.CreateTemplateFont(toolkitPreBuild, style.SizePx); font = this.CreateTemplateFont(toolkitPreBuild, style.SizePx);
this.attachments.Add((font, style, glyphRanges)); this.attachments.Add((font, style, glyphRanges));
return font; return font;

View file

@ -556,25 +556,11 @@ public static partial class ImGuiHelpers
.ToArray(); .ToArray();
/// <summary> /// <summary>
/// Determines whether <paramref name="ptr"/> is empty. /// Determines whether <paramref name="ptr"/> is not empty and loaded.
/// </summary> /// </summary>
/// <param name="ptr">The pointer.</param> /// <param name="ptr">The pointer.</param>
/// <returns>Whether it is empty.</returns> /// <returns>Whether it is not null and loaded.</returns>
public static unsafe bool IsNull(this ImFontPtr ptr) => ptr.Handle == null; public static unsafe bool IsNotNullAndLoaded(this ImFontPtr ptr) => !ptr.IsNull && ptr.IsLoaded();
/// <summary>
/// Determines whether <paramref name="ptr"/> is empty.
/// </summary>
/// <param name="ptr">The pointer.</param>
/// <returns>Whether it is empty.</returns>
public static unsafe bool IsNotNullAndLoaded(this ImFontPtr ptr) => ptr.Handle != null && ptr.IsLoaded();
/// <summary>
/// Determines whether <paramref name="ptr"/> is empty.
/// </summary>
/// <param name="ptr">The pointer.</param>
/// <returns>Whether it is empty.</returns>
public static unsafe bool IsNull(this ImFontAtlasPtr ptr) => ptr.Handle == null;
/// <summary> /// <summary>
/// If <paramref name="self"/> is default, then returns <paramref name="other"/>. /// If <paramref name="self"/> is default, then returns <paramref name="other"/>.
@ -583,7 +569,7 @@ public static partial class ImGuiHelpers
/// <param name="other">The other.</param> /// <param name="other">The other.</param>
/// <returns><paramref name="self"/> if it is not default; otherwise, <paramref name="other"/>.</returns> /// <returns><paramref name="self"/> if it is not default; otherwise, <paramref name="other"/>.</returns>
public static unsafe ImFontPtr OrElse(this ImFontPtr self, ImFontPtr other) => public static unsafe ImFontPtr OrElse(this ImFontPtr self, ImFontPtr other) =>
self.Handle is null ? other : self; self.IsNull ? other : self;
/// <summary> /// <summary>
/// Mark 4K page as used, after adding a codepoint to a font. /// Mark 4K page as used, after adding a codepoint to a font.