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

Add built_value test macro fields. #145

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

davidmorgan
Copy link
Contributor

I think this is enough to be interesting for performance questions.

In particular it checks whether field types are @BuiltValue classes, which obviously should use a more advanced query to be fast.

for (final field in fields) {
final qualifiedName = field.value.returnType.asNamedTypeDesc.name;
if (qualifiedName.uri != 'dart:core') {
fieldTypes.add(qualifiedName.asString);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we adding these as strings and then parsing them below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because QualifiedName is an extension type we can't dedupe it with a set, and have to go via String in order to do the query once per type instead of once per field.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, hmm that is unfortunate. It seems likely this would be a pretty common use case.

Related question... are we in a "Scope.macro" scope here? If so, when you call QualifiedName.parse, is that actually allocating an unused map into the JsonBuffer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes ... it's similarly annoying in the _resolveNames method in macro_implementation.dart.

And, yes, it ends up in the JsonBuffer. Definitely room for improvement :)

For this specific case though they should just all be fetched by one initial query, i.e. we want a way to say "and metadata of all field types". Or maybe "any metadata called BuiltValue of all field types"...

Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely seems like something to be done. Not sure what exactly though, don't have any ideas at the moment. It isn't something to block this PR on though in any case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks--I see you opened an issue, we can figure it out there :)

@davidmorgan davidmorgan merged commit 594abb2 into dart-lang:main Nov 25, 2024
51 checks passed
@davidmorgan davidmorgan deleted the built-value-fields branch November 25, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants