Jesse Phillips:
Somewhat interesting, Java has chosen to make substring result
in a copy of the string data rather than returning a window of
the underlying chars.
I presume in Java slices weren't very common, unlike in D. So I
think this is the right design choice for Java (also because
those Java strings are too much large, four instance fields), but
D is better designed as it is.
On the other hand the idea of putting the hash code inside the
string in D was not discussed enough :-)
From the discussion, Dmd associative arrays were designed like
this:
In Java 8 an improved solution devised by Doug Lea is used. In
this solution colliding but Comparable Map keys are placed in a
tree rather than a linked listed. Performance degenerates to
O(log n) for the collisions but this is usually small unless
someone is creating keys which intentionally collide or has a
very, very bad hashcode implementation, ie. "return 3".<
I am reminded of a denial of service attack that used
intentionally colliding request field names/values to attack web
servers and bringing down servers to their knees.<
Bye,
bearophile
- Re: Java moves to copying for substrings bearophile
-