-
Notifications
You must be signed in to change notification settings - Fork 752
Decref the members of Runtime(split from #958) #1019
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
* Unified GetBuiltins method
Codecov Report
@@ Coverage Diff @@
## master #1019 +/- ##
=======================================
Coverage 86.71% 86.71%
=======================================
Files 1 1
Lines 301 301
=======================================
Hits 261 261
Misses 40 40
Continue to review full report at Codecov.
|
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.
Feel free to ignore the NITs if you wish.
@@ -393,6 +415,19 @@ internal static int AtExit() | |||
return 0; | |||
} | |||
|
|||
private static void SetPyMember(ref IntPtr obj, IntPtr value, Action onRelease) |
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.
NIT: obj
can be out IntPtr
/// </summary> | ||
public void Add(IntPtr ob, Action onRelease) | ||
{ | ||
_actions.Add(new KeyValuePair<IntPtr, Action>(ob, onRelease)); |
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.
NIT: use Tuple<T1, T2>
, e.g. just _actions.Add((ob, onRelease))
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.
Why using Tuple? As my experience, with two elements cases, KeyValue would always faster than tuple(unless the struct is too big).
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.
Simply for readability. This code is not a hot path, so a little performance difference hardly matters.
Also, once we retarget to newer framework, C# will use ValueTuple
anyway.
foreach (var item in _actions) | ||
{ | ||
Runtime.XDecref(item.Key); | ||
item.Value?.Invoke(); | ||
} |
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.
NIT: use foreach(var (ob, onRelease) in _actions)
(requires modification from previous comment).
What does this implement/fix? Explain your changes.
Does this close any currently open issues?
...
Any other comments?
...
Checklist
Check all those that are applicable and complete.
AUTHORS
CHANGELOG