dotnet / dotnet/macios

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

Open
#12,679 0 comments 2 reactions 0 assignees View on GitHub
enhancement generator iOS macOS performance
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 13h
Merged PRs (30d)
96

Description

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

## Example (array)

```csharp
IntPtr retvalarrtmp;
ret = ((retvalarrtmp = global::ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper (this.SuperHandle, Selector.GetHandle ("gaugeColorLocations"))) == IntPtr.Zero ? null : (NSArray.ArrayFromHandleFunc (retvalarrtmp, ptr => {
using (var num = Runtime.GetNSObject (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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.