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

[Truffle] Privatise ByteList #4372

Merged
merged 7 commits into from Dec 9, 2016
Merged

[Truffle] Privatise ByteList #4372

merged 7 commits into from Dec 9, 2016

Conversation

chrisseaton
Copy link
Contributor

We can drop logic such as invalidating the hash, and space such as holding the hash and string value, if we privatise this.

this.stringValue = decoded = decode(bytes, begin, realSize, "ISO-8859-1");
}
return decoded;
return decode(bytes, begin, realSize, "ISO-8859-1");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"ISO-8859-1" is wrong here (it should just use the ByteList encoding to decode), so we could take this opportunity to fix it as well.

@nirvdrum
Copy link
Contributor

nirvdrum commented Dec 9, 2016

If we have our own copy of ByteList, we may as well remove all the unused methods.


public ByteListKey(ByteList bytes) {
this.bytes = bytes;
hash = Arrays.hashCode(bytes.bytes());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible that the ByteList changes and this would invalidate the hash. It looks like this is only used for regexp caching and that might be fine.

The second potential issue is ByteList#bytes always makes a copy. You could use ByteList#unsafeBytes instead, but you may have two equivalent ByteLists with different underyling byte arrays due to changing offsets or lengths. In which case, you'd want to call ByteList#unsafeBytes and loop through from ByteList#begin to ByteList#length.


ByteListKey that = (ByteListKey) o;

return bytes.equals(that.bytes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that ByteList#equals ignores encoding. This has been problematic in the past with things like our symbol table.

@chrisseaton chrisseaton merged commit 1e19263 into truffle-head Dec 9, 2016
@chrisseaton chrisseaton deleted the truffle-bytelist branch December 9, 2016 21:14
@enebo enebo modified the milestone: truffle-dev Jan 10, 2017
@enebo enebo added this to the Non-Release milestone Dec 7, 2017
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

Successfully merging this pull request may close these issues.

None yet

4 participants