• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Is it safe to do this?

Status
Not open for further replies.
Level 7
Joined
Apr 27, 2011
Messages
272
Hey guys is it safe to do this (i mean the subtraction part)

JASS:
 function MEEP takes handle H, string Label, integer Data returns nothing
    call SaveInteger(MEEP,GetHandleId(H)-8191,StringHash(Label)-8191,Data)
 endfunction

my reason for subtracting 8191 is to save some space in the game.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
to save some space in the game.

Why not do GetHandleId(H) - GetHandleId(null) instead of 8191? The number produced by GetHandleId(H) is far larger than 8191. I think it's either 0x100000 or 0x10008.

Either way, you're not really speeding anything up by reducing that number. Hash-tables don't work like arrays, their indexes are not directly representative of how much memory you'll need to store that.

You don't necessarily have to remove the StringHash part; depends how you want to interface it.
 
Trying to shrink values to store them into a hash table is a waste of time unless the value is somehow beyond 2^31 − 1 (which no native integer in JASS should be, whether it be rawcode or handle id).

The only excuse to "hash" stringhash is if you need to store it into an array, and the ASCII library does that quite well: http://www.hiveworkshop.com/forums/jass-functions-413/snippet-ascii-190746/
 
Status
Not open for further replies.
Top