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

Comments

Projects
None yet
3 participants
@keith-turner
Contributor

keith-turner commented Apr 24, 2017

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 keith-turner referenced this issue Apr 24, 2017

Closed

fixes #823 #825

@keith-turner

This comment has been minimized.

Show comment
Hide comment
@keith-turner

keith-turner Apr 24, 2017

Contributor

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

Contributor

keith-turner commented Apr 24, 2017

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

@cjmctague

This comment has been minimized.

Show comment
Hide comment
@cjmctague

cjmctague Apr 28, 2017

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?

Contributor

cjmctague commented Apr 28, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@keith-turner

keith-turner Apr 28, 2017

Contributor

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)

Contributor

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 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