Skip to content

Conversation

@BCSharp
Copy link
Member

@BCSharp BCSharp commented Feb 25, 2025

No description provided.

}

_fields = allFields.ToArray();
_fields = [..allFields];
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, never seen this syntax before. I haven't been keeping up with the more recent C# versions.

Not that I'm concerned about performance here, but is this smart enough to use ToArray (which is presumably more performant than a foreach statement)?

Copy link
Member Author

Choose a reason for hiding this comment

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

but is this smart enough to use ToArray

Yes, in this context it does, and in other contexts the compiler is allowed to do any other optimizations it is aware of. The .. operation is called now spread, which arguably is nicer than (but practically equivalent to) splat, which we discussed before.

@BCSharp BCSharp merged commit 62b2f65 into IronLanguages:main Feb 25, 2025
8 checks passed
@BCSharp BCSharp deleted the nullable_ctypes_struct branch February 25, 2025 20:32
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