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

[generator] Remove temporary creation of NSNumber instances in generated bindings #12679

Open
spouliot opened this issue Sep 9, 2021 · 0 comments
Labels
enhancement The issue or pull request is an enhancement generator Issues affecting the generator iOS Issues affecting iOS macOS Issues affecting macOS performance If an issue or pull request is related to performance
Milestone

Comments

@spouliot
Copy link
Contributor

spouliot commented Sep 9, 2021

Current code generation can create multiple NSNumber (alone or in an array) instance that needs to be allocated (and soon after disposed).

Example (array)

IntPtr retvalarrtmp;
ret = ((retvalarrtmp = global::ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper (this.SuperHandle, Selector.GetHandle ("gaugeColorLocations"))) == IntPtr.Zero ? null : (NSArray.ArrayFromHandleFunc <float> (retvalarrtmp, ptr => {
	using (var num = Runtime.GetNSObject<NSNumber> (ptr)) {
		return (float) num.FloatValue;
	}
})));

A more direct approach would be to use CFNumberGetValue [1] to avoid the extra costs.

[1] https://developer.apple.com/documentation/corefoundation/1543114-cfnumbergetvalue?language=objc

@spouliot spouliot added enhancement The issue or pull request is an enhancement macOS Issues affecting macOS iOS Issues affecting iOS labels Sep 9, 2021
@spouliot spouliot added this to the Future milestone Sep 9, 2021
@rolfbjarne rolfbjarne added generator Issues affecting the generator performance If an issue or pull request is related to performance labels Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue or pull request is an enhancement generator Issues affecting the generator iOS Issues affecting iOS macOS Issues affecting macOS performance If an issue or pull request is related to performance
Projects
None yet
Development

No branches or pull requests

2 participants