Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Scene] Add SceneStringName::hover #100036

Merged
merged 1 commit into from
Dec 11, 2024
Merged

Conversation

Chaosus
Copy link
Member

@Chaosus Chaosus commented Dec 5, 2024

Just an internal enhancement.

@Chaosus Chaosus requested review from a team as code owners December 5, 2024 08:29
@Chaosus Chaosus added this to the 4.4 milestone Dec 5, 2024
@AThousandShips
Copy link
Member

I think it'd be good to establish some kind of limit where this is considered relevant

Did you have some limit when cleaning out some cases @KoBeWi?

@Mickeon
Copy link
Contributor

Mickeon commented Dec 5, 2024

The difference between these two macros still rather puzzles me, at least some comments would be nice.

@AThousandShips
Copy link
Member

AThousandShips commented Dec 5, 2024

SNAME creates a static StringName in each place it is used, SceneStringNames is one single declaration that's reused:

SNAME:

  • Static variable so evaluated exactly once, the first pass of the scope
  • Not shared (AFAIK the compiler can't merge these due to volatile behaviour)

SceneStringName:

  • Uses a singleton
  • Allocated on startup
  • All uses of it are shared, and access should be optimized out

@KoBeWi
Copy link
Member

KoBeWi commented Dec 5, 2024

Did you have some limit when cleaning out some cases @KoBeWi?

I deleted names if they were used once or twice, so anything above would qualify. But it's different with adding new names. Technically adding new SceneStringNames has no downsides, but the more we have them, the more difficult is to keep track of them, which might eventually lead to inconsistencies like we had before. And opting for using a SceneStringName for everything is not very convenient. #99984 makes it easier to add new names, but it still requires major recompiling of the engine.
SNAME is a middle ground between performance and convenience. You can use it easily, but it comes with some drawbacks when overused.

SceneStringName:
Uses a singleton
Allocated on startup
All uses of it are shared, and access should be optimized out

They also prevent typos.

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

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

So as I said, we could technically add SceneStringName for everything, but that's lots of effort and not really worth it that much. If you went ahead and created another one then why not.

To keep consistency, we could create a script that detects missing usages of existing SceneStringNames. I think I had one when I was doing my cleanup🤔

@Chaosus Chaosus merged commit a40fc23 into godotengine:master Dec 11, 2024
20 checks passed
@Chaosus Chaosus deleted the hover_sname branch December 11, 2024 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants