CoreNLP icon indicating copy to clipboard operation
CoreNLP copied to clipboard

Excessive Arrays.fill in Java not necessary.

Open InputNeuron opened this issue 10 years ago • 2 comments

There is a lot of code in CoreNLP like the following:

    float[] initial = new float[domainDimension()];
    Arrays.fill(initial, 0.0f);

I counted 10-20 in just 15 seconds by looking at the code by grepping for Arrays.fill

This isn't needed as Java defaults to 0.0 for floats and doubles so this is just wasting time.

The only argument FOR it is if you're trying to force the RAM into a cache line but I don't see any commentary on this.

Otherwise it might be just wasting time.

If you're trying to force it into a cache line calling something like Cache.forceIntoCacheline (a new method) would be a better way to document this.

InputNeuron avatar Oct 24 '16 21:10 InputNeuron

I've removing all the ones that I can find, but that was < 20 (but > 15), so it must have been a quite exhaustive count!

manning avatar Nov 21 '16 04:11 manning

Awesome! I'll pull in the future here... I wonder if there are any static analysis tools that do a good job here. I will try to run findbugs when I get some time.

Thanks!

InputNeuron avatar Nov 21 '16 16:11 InputNeuron