Closed JarvisCraft closed 5 years ago
Hi! Thank you for your suggestions.
As I don't assume that there will not be accessed by many concurrent threads, I do not think that change to ConcurrentHashMap
would be useful.
Map#contains
has the exact same code as Map#get
. I agree that it's result can be cached.
The reason I suggest usage of ConcurrentHashMap
is that at current you use Collections.synchronizedMap
which, even in 1-threaded environment is slower due to synchronization of each of its operations.
<3
https://github.com/koca2000/NoteBlockAPI/blob/92b6a733ee116e5e5c382b303e23eeaf582f30f3/src/main/java/com/xxmicloxx/NoteBlockAPI/NoteBlockAPI.java#L32 Might be replaced with
ConcurrentHashMap
https://github.com/koca2000/NoteBlockAPI/blob/92b6a733ee116e5e5c382b303e23eeaf582f30f3/src/main/java/com/xxmicloxx/NoteBlockAPI/NoteBlockAPI.java#L54 Might be replaced withMap#contains
or result ofMap#get
may be cached not to be called twice