Constructor `String(String)` does not copy `hashIsZero`
Japris Pogrammer
mrjarviscraft at gmail.com
Mon Nov 22 21:20:40 UTC 2021
According to openjdk/jdk [1] current copy-constructor of String class does
not copy the value of hashIsZero field which may lead to 0-hash being
recalculated on copy even if it is known to be 0.
Could you please tell me if I am right with this point or if this behaviour
is intentional?
If this is actually a bug then I am ready to propose a trivial fix for
it[2].
[1]:
https://github.com/openjdk/jdk/blob/05a9a51dbfc46eb52bc28f1f9a618c75ee2597e9/src/java.base/share/classes/java/lang/String.java#L259-L264
[2]: https://github.com/JarvisCraft/jdk/tree/String-copy-zero-hashCode
More information about the core-libs-dev
mailing list