Skip to content

Commit 751831f

Browse files
committed
refactor(ConfigManager): 移除冗余检查以简化配置添加和移除逻辑
移除 AddConfig 方法中已存在配置时的提前返回检查,因为 TryAdd 方法本身具有幂等性 移除 RemoveConfig 方法中调用 HasConfig 的冗余检查,直接使用 TryRemove 方法
1 parent 9a801c2 commit 751831f

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

Runtime/Config/Config/ConfigManager.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,6 @@ public bool HasConfig(string configName)
123123
[UnityEngine.Scripting.Preserve]
124124
public void AddConfig(string configName, IDataTable configValue)
125125
{
126-
bool isExist = m_ConfigDatas.TryGetValue(configName, out var value);
127-
if (isExist)
128-
{
129-
return;
130-
}
131-
132126
m_ConfigDatas.TryAdd(configName, configValue);
133127
}
134128

@@ -143,11 +137,6 @@ public void AddConfig(string configName, IDataTable configValue)
143137
[UnityEngine.Scripting.Preserve]
144138
public bool RemoveConfig(string configName)
145139
{
146-
if (!HasConfig(configName))
147-
{
148-
return false;
149-
}
150-
151140
return m_ConfigDatas.TryRemove(configName, out _);
152141
}
153142

@@ -177,4 +166,4 @@ public void RemoveAllConfigs()
177166
m_ConfigDatas.Clear();
178167
}
179168
}
180-
}
169+
}

0 commit comments

Comments
 (0)