• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Which one takes up more memory: 4 reals or 1 rect?

Status
Not open for further replies.

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,550
Hello there.
I've been tinkering with structs for the past few months and have ran across a doubt: which one will take more memory: 4 reals or 1 rect? The reals are the rect's minX,minY,maxX,maxY.
JASS:
    real minx
    real miny
    real maxx
    real maxy
Using a rect also makes the create function shorter, but I will only create a fix number of these structs and they'll last for the entire game.


Thank you in advance!
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Rect also includes the creation and handling of the region behind it. I think that working with the 4 reals is faster.
 
  • Like
Reactions: Rui

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
The 4 reals are probably more memory efficient because they avoid all the extra object maintenence complexity which a rect needs. The reals might map directly to positions in a hash table meaning no extra memory usage unless they cause the hashtable to grow.
 
Status
Not open for further replies.
Top