-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Conversation
7180f26
to
e2a4664
Compare
this.stringValue = decoded = decode(bytes, begin, realSize, "ISO-8859-1"); | ||
} | ||
return decoded; | ||
return decode(bytes, begin, realSize, "ISO-8859-1"); |
There was a problem hiding this comment.
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.
…mply for everyone else.
e2a4664
to
3180e2b
Compare
If we have our own copy of |
|
||
public ByteListKey(ByteList bytes) { | ||
this.bytes = bytes; | ||
hash = Arrays.hashCode(bytes.bytes()); |
There was a problem hiding this comment.
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 ByteList
s 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); |
There was a problem hiding this comment.
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.
We can drop logic such as invalidating the hash, and space such as holding the hash and string value, if we privatise this.