Merge pull request #1876 from sk89q/oredictcache-fix

Fix some performance issues with OreDictCache
This commit is contained in:
Aidan 2014-10-02 11:16:47 -04:00
commit 26dadfe176
2 changed files with 6 additions and 5 deletions

View file

@ -22,7 +22,7 @@ public class ItemInfo
@Override
public boolean equals(Object obj)
{
return obj instanceof BlockInfo &&
return obj instanceof ItemInfo &&
((ItemInfo)obj).item == item &&
((ItemInfo)obj).meta == meta;
}
@ -31,8 +31,8 @@ public class ItemInfo
public int hashCode()
{
int code = 1;
code = 31 * code + item.getUnlocalizedName().hashCode();
code = 31 * code + meta;
code = 31 * code + System.identityHashCode(item);
code = 7 * code + meta;
return code;
}
}

View file

@ -24,10 +24,11 @@ public final class OreDictCache
}
ItemInfo info = ItemInfo.get(check);
List<String> cached = cachedKeys.get(info);
if(cachedKeys.get(info) != null)
if(cached != null)
{
return cachedKeys.get(info);
return cached;
}
int[] idsFound = OreDictionary.getOreIDs(check);