Skip to content

Conversation

@EttyKitty
Copy link
Owner

@EttyKitty EttyKitty commented Nov 20, 2024

I'm not 100% why, but you can't reference a macro directly, i.e. array_length(macro) fails on build. Because of that, I had to assign macro into local vars beforehand.

I just want to generally note: globals that are used as constants are a bad practice. Very bad.
image

Todo:

  • I want to see if it's possible to replace global static structs with something. Macro can't hold structs, so it should be something else. You can use a function, that'll return a struct, but this is no better in terms of reference overhead and additionally creates struct to be garbage collected on every call. So, no, there is no better way, I don' think.
  • Figure out if using static variables is actually worse for performance than locals. They are. Unless you want a variable to preform like a persistent instance variable of a function, that you can modify and reference throughout your code, kinda like a global var, you shouldn't use static vars. They take up memory and are never freed, the same way as globals.
    Honestly, I'm not even sure how are they different from globals. Maybe only in how you reference them, with function_name.static_name.

@EttyKitty EttyKitty added the PR: Performance Refactor that improves performance label Nov 20, 2024
@EttyKitty EttyKitty marked this pull request as draft November 20, 2024 12:48
@EttyKitty EttyKitty marked this pull request as ready for review November 20, 2024 13:26
Copy link

@OH296 OH296 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we come up with some sort of standardised syntax for macro names, imo it would remove chances for confusion?

@EttyKitty
Copy link
Owner Author

EttyKitty commented Nov 21, 2024

Can we come up with some sort of standardised syntax for macro names, imo it would remove chances for confusion?

Oh, my bad. I actually forgot about it.
We already have some, not sure what prefixes to use here tho.
image
Maybe a better idea to just use all CAPS for them.
I guess we can start naming them by what data type they are holding.
I.e. ARR_body_parts, STR_date_time, etc.

@OH296
Copy link

OH296 commented Nov 22, 2024

Can we come up with some sort of standardised syntax for macro names, imo it would remove chances for confusion?

Oh, my bad. I actually forgot about it. We already have some, not sure what prefixes to use here tho. image Maybe a better idea to just use all CAPS for them. I guess we can start naming them by what data type they are holding. I.e. ARR_body_parts, STR_date_time, etc.

forgot that this was probably on hold waiting for me to reply. I have no problem using the example approach

@EttyKitty EttyKitty merged commit 8ed5b4a into compile/main Nov 25, 2024
@EttyKitty EttyKitty deleted the refactor/globals branch November 25, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Performance Refactor that improves performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants