Closed eawagner closed 9 years ago
I would like to investigate this further, with good benchmarking.
LRUCache?
I was thinking just to store the byte arrays as class variables, so that we didn't create new arrays every time toByteArray() was called. Potentially, instead of storing the underlying InetAddress class, as that is simply redundant
That being said, the overhead of creating such small arrays is very small, so I want to run some benchmarks to see what the benefits are to different approaches.
The reason for this is that every comparison uses the byte array from InetAddress.getAddress().
The problem is that this method generates a new byte array for each address in the comparison. This happens for every comparison, causing a lot of small byte arrays to get created on the heap. It is better to simply cache the byte array to make the comparison operations faster.