9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 09:59:20 +00:00

refactor(entity): 优化代码

This commit is contained in:
jhqwqmc
2025-06-20 13:49:14 +08:00
parent f25b7ed813
commit 4eb75bf84b

View File

@@ -12,18 +12,13 @@ public final class ClassTreeIdRegistry {
public int getLastIdFor(Class<?> clazz) {
int cachedId = this.classToLastIdCache.getInt(clazz);
if (cachedId == -1) {
Class<?> currentClass = clazz;
while ((currentClass = currentClass.getSuperclass()) != Object.class) {
int parentCachedId = this.classToLastIdCache.getInt(currentClass);
if (parentCachedId != -1) {
return parentCachedId;
}
}
return -1;
} else {
return cachedId;
if (cachedId != -1) return cachedId;
Class<?> currentClass = clazz;
while ((currentClass = currentClass.getSuperclass()) != Object.class) {
int parentCachedId = this.classToLastIdCache.getInt(currentClass);
if (parentCachedId != -1) return parentCachedId;
}
return -1;
}
public int define(Class<?> clazz) {