I was playing around with my prime sieving implementation and I managed to improve the performance by making some simple changes. The code looks quite a bit different, but functionally it does basically the same thing. The one big difference is that I switched the code to use arrays instead of ArrayLists. Through some testing I realized that there was a fairly significant performance difference between arrays and ArrayLists. The actual problem has to deal with Java generics and boxing of primitives. I may go more into the details at a later date. It's a rather specialized optimization and for the vast majority of programs shouldn't be necessary. Other than that, the code is generally more readable.
Read more »↧