• 🏆 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] 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,202
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