TonicBox
TonicBox
JCHJava Community | Help. Code. Learn.
Created by Lantanggamer on 1/21/2025 in #java-help
Is there a way to optimize my code more?
Yeah I was more responding to the suggestion of hashmaps. That's all true too though.
40 replies
JCHJava Community | Help. Code. Learn.
Created by Lantanggamer on 1/21/2025 in #java-help
Is there a way to optimize my code more?
. So to optimise this, I'd recommend to rewrite it in a way that uses primatives and Arrays. Stear clear of boxing/unboxing as much as possible.
40 replies
JCHJava Community | Help. Code. Learn.
Created by Lantanggamer on 1/21/2025 in #java-help
Is there a way to optimize my code more?
Speed & Efficiency: Arrays & Primitives are super fast because they store data in a contiguous block of memory. This means quick access and better cache performance. HashMaps & Lists have extra layers (like hashing or node traversal) which add overhead and can slow things down. Memory Usage: Arrays use less memory since they hold data directly. Collections like HashMaps often use wrapper objects (e.g., Integer vs. int), which take up more space and can lead to autoboxing/unboxing overhead. Access & Operations: Arrays offer constant-time access with simple indexing. HashMaps require computing hash codes and handling collisions, while Lists (especially linked lists) might need to traverse elements, making operations slower. CPU & Optimization: Arrays benefit from better cache locality and allow the JVM’s JIT compiler to optimize code more effectively. HashMaps & Lists have less predictable memory access patterns, leading to cache misses and fewer optimization opportunities. Garbage Collection: Collections generate more temporary objects, increasing the garbage collector’s workload and potentially impacting performance. Arrays & Primitives are more lightweight, putting less strain on the GC.
40 replies
JCHJava Community | Help. Code. Learn.
Created by Lantanggamer on 1/21/2025 in #java-help
Is there a way to optimize my code more?
Largely due to the boxing/unboxing that lists and maps necessitate as opposed to sticking with primatives
40 replies
JCHJava Community | Help. Code. Learn.
Created by Lantanggamer on 1/21/2025 in #java-help
Is there a way to optimize my code more?
Maps and lists only get faster when you get into really large sets of data
40 replies
JCHJava Community | Help. Code. Learn.
Created by Lantanggamer on 1/21/2025 in #java-help
Is there a way to optimize my code more?
It will have more bytecode/processing overhead.
40 replies
JCHJava Community | Help. Code. Learn.
Created by TonicBox on 12/13/2022 in #java-help
Pathfining stuff
ill probably just implement it into a custom A* algo ig though for the local scene pathing
9 replies
JCHJava Community | Help. Code. Learn.
Created by TonicBox on 12/13/2022 in #java-help
Pathfining stuff
yes but, if opening it is the shortest way, or the only way, want to factor that in, in a decently efficient manor
9 replies
JCHJava Community | Help. Code. Learn.
Created by TonicBox on 12/13/2022 in #java-help
Pathfining stuff
Yes but again tile collision if the door is closed wouldnt allow for a path. I suppose i could add a custom case for such objects in pathing and assign a higher weight or something to them to acc if some other door is open already. But that feel kinda hacky. Tho if there isnt a more targetted way to handle it can definitely do that
9 replies
JCHJava Community | Help. Code. Learn.
Created by TonicBox on 12/13/2022 in #java-help
Pathfining stuff
Yes. Atm for long distance mapping im using jump point first. For part of local pathing looking for something more targetted towards traversing an edge till it finds a tile with a door/gate/etc that would enable a complete patch to the target. If the entrance obj is closed normal pathing like that wouldnt find a complete path to the target tile
9 replies
JCHJava Community | Help. Code. Learn.
Created by TonicBox on 11/26/2022 in #java-help
Changing a classfile version level with javassist
After a day of searching, I answered my own question nearly immediately after posting this xd For anyone else in the future curious, the needed methods are in:
ClassFile::setMajorVersion()
ClassFile::setMinorVersion()
ClassFile::setMajorVersion()
ClassFile::setMinorVersion()
5 replies