Timeline for What is the benefit of caching a hash value in a string object?
Current License: CC BY-SA 4.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 13, 2022 at 3:01 | history | tweeted | twitter.com/StackSoftEng/status/1580393225767903232 | ||
Oct 9, 2022 at 18:46 | vote | accept | Kaz | ||
Oct 9, 2022 at 18:45 | comment | added | Kaz | @gapsf That is correct. I simply cargo culted it because it's been done elsewhere. I've removed the feature. The word which was made available in the string object for it is staying though; that part isn't reverted. It can be put to other uses. For instance, we can speed up the printing of strings if a flag indicates that they don't contain any characters requiring escape code rendering: just put out a double quote, dump the data, and close the quote. | |
Oct 9, 2022 at 6:16 | comment | added | gapsf | "What is the benefit of caching a hash value in a string object?" Asking means you dont understand what for you implement it in first place | |
Oct 8, 2022 at 23:04 | comment | added | Nat | @Kaz: @casablanca's answer seems to give a likely answer, i.e. that the JVM makes heavier use of hashes to support features like that compress/reduce strings. | |
Oct 8, 2022 at 20:18 | answer | added | casablanca | timeline score: 7 | |
Oct 8, 2022 at 18:47 | comment | added | Kaz | Speaking of Java specifically: is there some internal reason for this feature? Maybe the JVM uses strings for some purposes where it helps? If I don't have a similar scenario, then that would be a point against doing this. | |
Oct 7, 2022 at 23:30 | comment | added | Kaz | @AlexeiLevenkov I'm a language maintainer. Obviously, I coded this thing due to the suspicion it might be useful and has precedent in other people's projects. It's code complete and all; tests pass, and it's in an unpublished commit. But now, I don't see how to demonstrate how it is worthwhile; why have others done this. Expert programmers using languages which have this should know this sort of thing. | |
Oct 7, 2022 at 22:42 | answer | added | gnasher729 | timeline score: 0 | |
Oct 7, 2022 at 20:02 | comment | added | Doc Brown | This is a really good question, but some people here (which voted to close this as "opinionated") are too dumb to see that such a design decision must have been made deliberately. For Java strings, I am sure there was nothing just done by chance in their internal implementation. | |
Oct 7, 2022 at 20:01 | comment | added | Alexei Levenkov | Can you edit to clarify that you are not looking for feedback on how stupid is to make changes that you don't think are useful? | |
Oct 7, 2022 at 19:27 | review | Close votes | |||
Oct 13, 2022 at 3:03 | |||||
Oct 7, 2022 at 19:08 | answer | added | Philip Kendall | timeline score: -3 | |
Oct 7, 2022 at 19:04 | history | asked | Kaz | CC BY-SA 4.0 |