• 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.

Efficiency in struct

Status
Not open for further replies.
Level 18
Joined
Sep 14, 2012
Messages
3,413
Okay this thread is mad efficiency so if you're not on this don't say pointless optimization.

I'll show first the fact.

JASS:
scope Test
    struct a extends array
        unit u
    endstruct
endscope
Outputs this
JASS:
//JASSHelper struct globals:
constant integer si__a=1
unit array s__a_u

So for normal structs (outside the extends array I just want the variables), the name is like this : s__nameofstruct__nameofmember

JASS:
scope Test
    private struct a extends array
        unit u
    endstruct
endscope
Outputs this
JASS:
//JASSHelper struct globals:
constant integer si__Test___a=1
unit array s__Test___a_u

So for private structs the name is like this : s__nameofscope___nameofstruct_nameofmember

JASS:
scope Test
    struct a extends array
        private unit u
    endstruct
endscope
Outputs this
JASS:
//JASSHelper struct globals:
constant integer si__a=1
unit array s__a_u

Exactly the same as non_privated struct :O !!!!

And now for the last.
JASS:
scope Test
    private struct a extends array
        private unit u
    endstruct
endscope
Outputs this
JASS:
//JASSHelper struct globals:
constant integer si__Test___a=1
unit array s__Test___a_u

Exactly the same as just privated struct !




SO to sum up this :
- normal struct name : s__nameofstruct__nameofmember
- private struct name : s__nameofscope___nameofstruct_nameofmember
- normal struct private member : s__nameofstruct__nameofmember
- private struct private member : s__nameofscope___nameofstruct_nameofmember

Would this mean that using non-private struct and using everything private inside is faster :vw_wtf: ?
What do you think of it ?
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
if you so care about efficiency, run it through optimizer :D that will reduce it far beyond what you can achieve with this(1, 2 or 3 characters long function names and variable names)

but imo, you should use what fits more, if you want to have struct that is invisible outside of scope, use private struct with normal member data(you wont abuse your own code will you), if you have struct that any scope can see(public one), and you dont want certain variables to be overwriten by users, mark them private
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
if you so care about efficiency, run it through optimizer :D that will reduce it far beyond what you can achieve with this(1, 2 or 3 characters long function names and variable names)

but imo, you should use what fits more, if you want to have struct that is invisible outside of scope, use private struct with normal member data(you wont abuse your own code will you), if you have struct that any scope can see(public one), and you dont want certain variables to be overwriten by users, mark them private

this.

public/private modifiers are only for compiletime checks, so yea they compile to the same code (vanilla jass doesnt know public/private).
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
I didn't want to create a debate on how to use private/public ^^'
I know pretty well how all of this is working xD

But I found this pretty funny that private members do not have more letters than normal members and I though that can be cool to share.

I know about optimizer I was sure that someone would tell me this ^^
 
Status
Not open for further replies.
Top