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 f956f185c8
commit 10848b4104
No known key found for this signature in database
GPG key ID: 401ADFC9891FAAFE
3 changed files with 346 additions and 146 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