-
Notifications
You must be signed in to change notification settings - Fork 3
kn: address misc issues #173
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
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
| val kShouldSignHeaderFn = userData.asStableRef<ShouldSignHeaderFunction>().get() | ||
| val kShouldSignHeaderStableRef = userData.asStableRef<ShouldSignHeaderFunction>() | ||
| val kShouldSignHeaderFn = kShouldSignHeaderStableRef.get() | ||
| val kHeaderName = headerName.pointed.toKString() | ||
| return kShouldSignHeaderFn(kHeaderName) | ||
| return kShouldSignHeaderFn(kHeaderName).also { | ||
| kShouldSignHeaderStableRef.dispose() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Is it important to dispose stable refs even when an exception occurs? If so, I think your use method may be appropriate here:
userData.asStableRef<ShouldSignHeaderFunction>().use { kShouldSignHeaderStableRef ->
val kShouldSignHeaderFn = kShouldSignHeaderStableRef.get()
val kHeaderName = headerName.pointed.toKString()
return kShouldSignHeaderFn(kHeaderName)
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is, we should be disposing every StableRef created. I updated to use the use method
| } finally { | ||
| ctxStableRef.dispose() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Would it be better to use your use method here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we should!
| pointer.pointed.buffer = if (dest.isNotEmpty()) { | ||
| pinned.addressOf(0).reinterpret() | ||
| } else { | ||
| null | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style:
takeIf or takeUnless can clean this up a bit:
pointer.pointed.buffer = pinned.takeUnless { dest.isEmpty() }?.addressOf(0)?.reinterpret()
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
|
Affected ArtifactsChanged in size
|



Issue #, if available:
Description of changes:
Address various issues raised during code review
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.