Hacker News new | past | comments | ask | show | jobs | submit login

Using sun.misc.Unsafe to access array elements would make it much faster. Also ArrayList with preset size is faster for inserting elements.



Using sun.misc.Unsafe to access array elements would make it much faster.

sun.misc.Unsafe should not make any difference to performance here. OK, you skip bounds checks, but modern VMs are very good at optimising those away anyway.

Also ArrayList with preset size is faster for inserting elements.

Exactly what I was thinking. The only case this is really going to help is where you don't have an idea of what the size is going to be.


Decompression on byte[] is 3x faster with unsafe. I think modern JVMs are far from optimal.


Yes, that may be true for byte[], but there's no primitive types in play here. Java collections hold object types only.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: