Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excessive Arrays.fill in Java not necessary. #286

Closed
burtonator opened this issue Oct 24, 2016 · 2 comments
Closed

Excessive Arrays.fill in Java not necessary. #286

burtonator opened this issue Oct 24, 2016 · 2 comments

Comments

@burtonator
Copy link

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.

@manning
Copy link
Member

manning commented Nov 21, 2016

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!

@burtonator
Copy link
Author

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!

rocwzp pushed a commit to rocwzp/CoreNLP that referenced this issue Dec 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants