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

Type#GetLoadDependencies(): VERIFY() that only config object types are returned #10169

Merged
merged 2 commits into from
Sep 20, 2024

Conversation

Al2Klimov
Copy link
Member

No description provided.

@Al2Klimov Al2Klimov added the core/quality Improve code, libraries, algorithms, inline docs label Sep 20, 2024
@cla-bot cla-bot bot added the cla/signed label Sep 20, 2024
@yhabteab
Copy link
Member

No way, you are introducing yet another confusing loop! Please merge this with the existing loop that performs a nullptr check.

@Al2Klimov
Copy link
Member Author

But this looks so cool:

const std::unordered_set<Type*>& TypeImpl<Service>::GetLoadDependencies() const
{
	static const auto deps ([] {
		auto typeApiListener (GetByName("ApiListener").get());
		auto typeEndpoint (GetByName("Endpoint").get());
		auto typeHost (GetByName("Host").get());
		auto typeZone (GetByName("Zone").get());

		VERIFY(typeApiListener);
		VERIFY(typeEndpoint);
		VERIFY(typeHost);
		VERIFY(typeZone);

		VERIFY(ConfigObject::TypeInstance->IsAssignableFrom(typeApiListener));
		VERIFY(ConfigObject::TypeInstance->IsAssignableFrom(typeEndpoint));
		VERIFY(ConfigObject::TypeInstance->IsAssignableFrom(typeHost));
		VERIFY(ConfigObject::TypeInstance->IsAssignableFrom(typeZone));

		return std::unordered_set<Type*>{ typeApiListener, typeEndpoint, typeHost, typeZone, };
	}());

	return deps;
}

@yhabteab
Copy link
Member

Seriously, it's all about coolness? :-)

With every bit of such a useless loop you slow down the compilation process, so I'd rather group them like this instead:

VERIFY(typeApiListener);
VERIFY(ConfigObject::TypeInstance->IsAssignableFrom(typeApiListener));

...

@Al2Klimov Al2Klimov force-pushed the Type-GetLoadDependencies-ConfigObject branch from b8396a6 to b6517c6 Compare September 20, 2024 12:35
@yhabteab yhabteab added this to the 2.15.0 milestone Sep 20, 2024
@yhabteab yhabteab merged commit 4f690a6 into master Sep 20, 2024
26 checks passed
@yhabteab yhabteab deleted the Type-GetLoadDependencies-ConfigObject branch September 20, 2024 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla/signed core/quality Improve code, libraries, algorithms, inline docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants