4 ms·
String on its own is inefficient class. There is extra pointer, int field... ASCII strings are not downgraded from char[] to byte[]... You get big performance
by jkot 11y ago
String on its own is inefficient class. There is extra pointer, int field... ASCII strings are not downgraded from char[] to byte[]... You get big performance bonus just by replacing String with raw byte[].
I wrote Map<String,String> which does this transparently, and it consumes about 5x less memory compared to HashMap<String,String>.
- joajoa 11y agoIt's not that simple. See [1] and [2] [1] https://bugs.openjdk.java.net/browse/JDK-8054307 https://bugs.openjdk.java.net/browse/JDK-8054307 [2] http://shipilev.net/blog/2015/black-magic-method-dispatch/ http://shipilev.net/blog/2015/black-magic-method-dispatch/
- hyperpape 11y agoIt's been a little while since I read the method dispatch post...can you explain what you're driving at?
- MichaelGG 11y agoYeah I wish C# had a flag for this. UTF-16 is stupid, and in so, so many cases, it's just a pure loss with no benefits at all.