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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user