Skip to content

Commit

Permalink
Use partially synchronized map in Event hasAnnotation cache.
Browse files Browse the repository at this point in the history
Signed-off-by: Ross Allan <rallanpcl@gmail.com>
  • Loading branch information
LunNova committed Jun 20, 2013
1 parent e638864 commit 600ae33
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/common/nallar/patched/forge/PatchEvent.java
@@ -1,12 +1,11 @@
package nallar.patched.forge;

import java.util.concurrent.ConcurrentHashMap;

import nallar.collections.PartiallySynchronizedMap;
import net.minecraftforge.event.Cancelable;
import net.minecraftforge.event.Event;

public abstract class PatchEvent extends Event {
private static final ConcurrentHashMap<Class, Boolean> annotationMap = new ConcurrentHashMap<Class, Boolean>();
private static final PartiallySynchronizedMap<Class, Boolean> annotationMap = new PartiallySynchronizedMap<Class, Boolean>();

@Override
protected boolean hasAnnotation(Class annotation) {
Expand All @@ -17,7 +16,7 @@ protected boolean hasAnnotation(Class annotation) {
}
Class searchClass = cls;
while (searchClass != Event.class) {
if (searchClass.isAnnotationPresent(Cancelable.class)) // Forge bug, not fixed. Buggy behaviour may be required for some mods.
if (searchClass.isAnnotationPresent(Cancelable.class)) // TODO: Forge bug, not fixed. Buggy behaviour may be required for some mods.
{
annotationMap.put(cls, true);
return true;
Expand Down

0 comments on commit 600ae33

Please sign in to comment.