• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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