Stringhash("Popcorn") == StringHash("Cornpop") ?

Kuberr24

Well-Known Member
Reaction score
28
Just wondering, how exactly is a string converted to an integer?

Also, is it (although unlikely) possible to overwrite a value stored in a hashtable by for example using StringHash("popcorn") as a childkey, and accidently using 5156842 as a childkey for another value, under the assumption that StringHash("popcorn") = 5156842.

So basicly I'm wondering, is the integer generated with StringHash really SO TOTALLY UNIQUE it is impossible to get the same integer through other means?
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I've heard it's also slash insensitive, and probably other stuff like that.
I don't really care, since i don't have the use.
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
I've heard it's also slash insensitive, and probably other stuff like that.
I don't really care, since i don't have the use.
My theory is that it uses some windows file path hashing function internally. Windows file paths are also slash and case insensitive ^^

Unless blizzard did a bad job, the chance that the hash for two arbitrary (not equal) strings is equal should be very close to 0 (1/2^32). Though, if you use StringHash with constant strings then you better just create an appropriately named integer variable with a unique value and use that instead or use vjass keys.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Yep, i don't need a dynamic string as a key, that's why i don't need this function.
Well, except for debugging purposes, but that doesn't matter that much.

I guess Darthfett, the string lover, have some use of it.

But StringHash was mostly done to the gamecache -> hashtable conversion, for DoTa i guess.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
> I've heard it's also slash insensitive, and probably other stuff like that.

I head the same thing.

> But StringHash was mostly done to the gamecache -> hashtable conversion

Yeah, and a few other things. String libraries probably use this a lot.
 

Vexorian

Why no custom sig?
Reaction score
187
My theory is that it uses some windows file path hashing function internally. Windows file paths are also slash and case insensitive ^^

Unless blizzard did a bad job, the chance that the hash for two arbitrary (not equal) strings is equal should be very close to 0 (1/2^32). Though, if you use StringHash with constant strings then you better just create an appropriately named integer variable with a unique value and use that instead or use vjass keys.
Your theory seems way off.

They are just probably using gamecache's hashing. They probably made gamecache case insesntive in an effort to make it more accessible to the lowest denominator... You might be wondering why not just make the BJ functions case insensitive and let GUI use them? Well, for once the StringCase native didn't even exist in retail wc3. They did not think something like that was useful until there was a lot of insistence...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top