feat: explicit null checks

This commit is contained in:
mob-sakai
2026-03-24 17:32:31 +09:00
parent 04c1ca72cd
commit 319ab5fe06
15 changed files with 98 additions and 80 deletions

View File

@@ -48,7 +48,7 @@ namespace Coffee.UIParticleInternal
public static void LogIf(bool enable, object tag, object message, Object context = null)
{
if (!enable) return;
Log_Internal(LogType.Log, tag, message, context ? context : tag as Object);
Log_Internal(LogType.Log, tag, message, context != null ? context : tag as Object);
}
#if !ENABLE_COFFEE_LOGGER
@@ -56,7 +56,7 @@ namespace Coffee.UIParticleInternal
#endif
public static void Log(object tag, object message, Object context = null)
{
Log_Internal(LogType.Log, tag, message, context ? context : tag as Object);
Log_Internal(LogType.Log, tag, message, context != null ? context : tag as Object);
}
#if !ENABLE_COFFEE_LOGGER
@@ -64,13 +64,13 @@ namespace Coffee.UIParticleInternal
#endif
public static void LogWarning(object tag, object message, Object context = null)
{
Log_Internal(LogType.Warning, tag, message, context ? context : tag as Object);
Log_Internal(LogType.Warning, tag, message, context != null ? context : tag as Object);
}
public static void LogError(object tag, object message, Object context = null)
{
#if ENABLE_COFFEE_LOGGER
Log_Internal(LogType.Error, tag, message, context ? context : tag as Object);
Log_Internal(LogType.Error, tag, message, context != null ? context : tag as Object);
#else
Debug.LogError($"{tag}: {message}", context);
#endif

View File

@@ -29,7 +29,7 @@ namespace Coffee.UIParticleInternal
public static void Destroy(Object obj)
{
if (!obj) return;
if (obj == null) return;
#if UNITY_EDITOR
if (!Application.isPlaying)
{
@@ -44,7 +44,7 @@ namespace Coffee.UIParticleInternal
public static void DestroyImmediate(Object obj)
{
if (!obj) return;
if (obj == null) return;
#if UNITY_EDITOR
if (Application.isEditor)
{
@@ -61,7 +61,7 @@ namespace Coffee.UIParticleInternal
public static void SetDirty(Object obj)
{
#if UNITY_EDITOR
if (!obj) return;
if (obj == null) return;
EditorUtility.SetDirty(obj);
#endif
}
@@ -117,11 +117,11 @@ namespace Coffee.UIParticleInternal
foreach (var type in types)
{
var script = scripts.FirstOrDefault(x => x.GetClass() == type);
if (!script) continue;
if (script == null) continue;
var path = type.GetCustomAttribute<IconAttribute>()?._path;
var icon = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
if (!icon) continue;
if (icon == null) continue;
s_SetIconForObject(script, icon);
}

View File

@@ -90,7 +90,7 @@ namespace Coffee.UIParticleInternal
Profiler.BeginSample("(COF)[ObjectRepository] GetFromCache");
if (_cache.TryGetValue(hash, out var entry))
{
if (!entry.storedObject)
if (entry.storedObject == null)
{
Release(ref entry.storedObject);
Profiler.EndSample();
@@ -116,7 +116,7 @@ namespace Coffee.UIParticleInternal
private void Add(Hash128 hash, ref T obj, T newObject)
{
if (!newObject)
if (newObject == null)
{
Release(ref obj);
obj = newObject;
@@ -151,7 +151,7 @@ namespace Coffee.UIParticleInternal
&& _cache.TryGetValue(hash, out var entry))
{
entry.reference--;
if (entry.reference <= 0 || !entry.storedObject)
if (entry.reference <= 0 || entry.storedObject == null)
{
Remove(entry);
}
@@ -192,7 +192,7 @@ namespace Coffee.UIParticleInternal
public void Release(Action<T> onRelease)
{
reference = 0;
if (storedObject)
if (storedObject != null)
{
onRelease?.Invoke(storedObject);
}