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 typed array helpers for IsArray and AsArray #971

Merged
merged 3 commits into from Oct 1, 2021

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Oct 1, 2021

  • moved Is and As helpers to extensions methods
  • added Is and As helpers for each supported typed array type

internal T[] ToNativeArray<T>()
{
var conversionType = typeof(T);
var elementSize = _arrayElementType.GetElementSize();
Copy link
Owner

Choose a reason for hiding this comment

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

I believe this could be a static field?

Copy link
Owner

Choose a reason for hiding this comment

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

super nit right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Size is calculated via switch as there's only one TypeArrayInstance type and no specific for each one, it should be quite cheap...

Copy link
Owner

Choose a reason for hiding this comment

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

I agree. It just reminded me this trick that things on the generic type can be done statically without interfering between types.

@lahma lahma merged commit 21d1dc1 into sebastienros:main Oct 1, 2021
@lahma lahma deleted the as-typed-array branch October 1, 2021 16:27
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.

None yet

2 participants