Concurrency and Performance Improvements to DataFixers

Found some more unsafe operations in DataFixers.

Also replaced quite a few bad uses of Map.containsKey

containsKey is a common newbie mistake that "reads" cleaner, but
results in double the performance cost of all map operations as
containsKey in MOST cases where null values are not used is identical to get() == null

Considering how deep datafixers go in call stacks, with tons of map lookups,
this micro optimization could provide some gains.

Additionally, many of the containsKey/get/put style operations were
also a concurrency risk, resulting in multiple computation/insertions.
This commit is contained in:
Aikar
2018-09-15 13:22:14 -04:00
parent 47ff1783bc
commit 69b80568e9
3 changed files with 344 additions and 144 deletions

View File

@ -105,7 +105,12 @@ done
importLibrary com.mojang datafixerupper com/mojang/datafixers \
schemas/Schema.java \
DataFixerUpper.java \
NamedChoiceFinder.java \
functions/PointFree.java \
types/Type.java \
types/DynamicOps.java \
types/templates/Tag.java \
types/templates/TaggedChoice.java \
types/families/RecursiveTypeFamily.java
# dont forget \ at end of each line but last