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

Avoid using bytesAt() internally in Bytes #826

Closed
keith-turner opened this issue Apr 24, 2017 · 3 comments
Closed

Avoid using bytesAt() internally in Bytes #826

keith-turner opened this issue Apr 24, 2017 · 3 comments
Milestone

Comments

@keith-turner
Copy link
Contributor

I noticed that multiple methods inside Bytes use the byteAt method in loops. It would be more efficient to access the array directly because byteAt does sanity checks for each access. It would better to sanity check the entire range before the loop and directly access the array inside the loop. This improvement could be made to at least the following methods : hashCode() and compareTo.

@keith-turner
Copy link
Contributor Author

Can also avoid continually adding the offsets by doing it once outside the loops.

@cjmctague
Copy link
Contributor

@keith-turner Could we use the java helper methods like Objects.hashCode(this);for hashCode() in Bytes like is used in the rest of the API?

@keith-turner
Copy link
Contributor Author

keith-turner commented Apr 28, 2017

Could we use the java helper methods like Objects.hashCode(this);for hashCode() in Bytes like is used in the rest of the API?

@cjmctague if you can find something. I couldn't find a built in java method that takes an offset and length. Java has Arrays.hashCode(byte[]), but to use this we would need to create a new byte array and copy to it. Too bad java doesn't have Arrays.hashCode(byte[] data, int offset, int len)

@asfgit asfgit closed this as completed in a1c869c Apr 28, 2017
@mikewalch mikewalch added this to the 1.1.0 milestone May 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants