Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions druntime/src/core/gc/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ __gshared Config config;

private __gshared bool _initialized;

package(core) bool initialize(ref Config cfg) nothrow @nogc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

marking this package(core) means regular users cannot call this function. Is this intended?

@denizzzka denizzzka Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes: by the time regular users can call it it's already been called and tryToInitialize() won't be executed a second time because _initialized == true

{
if (!_initialized)
_initialized = cfg.tryToInitialize();

return _initialized;
}

struct Config
{
bool disable; // start disabled
Expand All @@ -37,11 +45,9 @@ struct Config

@nogc nothrow:

bool initialize()
private bool tryToInitialize()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made it private here because method name changed anyway.
If we need to be able initialize it somewhere externally (a second instance of Config, for example) we can change that in the future. But I think this is not needed

{
if (!_initialized)
_initialized = initConfigOptions(this, "gcopt");
return _initialized;
return initConfigOptions(this, "gcopt");
}

void help() @nogc nothrow
Expand Down
Loading