• 🏆 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!

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