| 09-19-2009, 02:10 AM | #1 |
StringHash("BLIZZARD IS RETARDED") == StringHash("blizzard is retarded")
is true. Apparantly Blizzard did a retarded implementation of StringHash. |
| 09-19-2009, 02:14 AM | #2 |
Sounds more like they wanted to make it easier to move on from gamecache to them . |
| 09-19-2009, 02:29 AM | #3 | |
Quote:
Was gamecache case-insensitive? Whoa. BTW I've written a function to deal with this. While this is quite slower than a single native call, it will prove useful when case sensitivity is important. This will be included in StringUtils library. JASS:function StringHashCS takes string s returns integer local integer ri = 0 local integer li = 0 local integer length = StringLength(s) local string result = "" local string ss loop exitwhen ri >= length set ss = SubString(s, ri, ri+1) if ss == "\\" then set result = result + SubString(s, li, ri) + "\\\\" set ri = ri + 1 set li = ri elseif StringCase(ss, false) != ss then // this is a uppercase character; make it different. set result = result + SubString(s, li, ri) + "\\" + ss set ri = ri + 1 set li = ri else set ri = ri + 1 endif endloop set result = result + SubString(s, li, length) return StringHash(result) endfunction |
| 09-19-2009, 03:41 PM | #4 |
Good to know. |
| 09-20-2009, 06:30 PM | #5 |
I was expecting a post about the fact that the string is hashed *before* passing it to the function, meaning there are non-equivalent strings which will overwrite each other. Who cares about case insensitivity, when that bug-waiting-to-happen exists? |
| 09-20-2009, 07:08 PM | #6 |
StringHash also features "slash insensitivity." |
| 09-21-2009, 01:16 PM | #7 | ||
Quote:
What do you mean? Edit: Oh, I see. You mean the hash collision issue. Yes, it is a problem, but there are standard ways to circumvent that problem. However, since Jass doesn't support polymorphism pretty much there was no way to incorporate that inside hashtable implementation. It has to be done manually. Should I make a library for that? BTW StringLib doesn't have any problem from this since hash is only used to determine each bytes, and confirmed no hash collision among them. Quote:
|
| 09-21-2009, 03:16 PM | #8 |
Well, i guess if we really need strings to save datas, game cache is the way. |
| 09-21-2009, 05:28 PM | #9 | |
Quote:
|
| 09-21-2009, 05:43 PM | #10 | ||
Quote:
Quote:
|
| 09-21-2009, 05:56 PM | #11 | |
Quote:
No it's not. The main thing Game Cache has going for it is ... uh ... nothing. I guess it doesn't have the string collision issue, but it's vulnerable to malicious clients injecting values. |
| 09-21-2009, 06:38 PM | #12 |
Hmm ok, so just forgot what i've said ... |
| 09-21-2009, 07:02 PM | #13 |
People use StringHash? I thought that was mainly for backwards compatibility. |
| 09-21-2009, 07:07 PM | #14 |
Personally, i don't use it. Currently i can't figure a case where strings are absolutely needed to link a data, where you can't do it with an integer instead. But again, maybe i'm wrong ... |
| 09-21-2009, 07:31 PM | #15 |
I use it for storing and retrieving actions associated with mode commands. I have asserts to ensure there are no collisions (and the commands don't change, so it's safe). |
