-
Notifications
You must be signed in to change notification settings - Fork 1
Release 0.5.1 #6
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
using UnityEngine.SceneManagement; | ||
using Object = UnityEngine.Object; | ||
|
||
#nullable enable | ||
// ReSharper disable once CheckNamespace | ||
|
||
namespace GameLovers | ||
|
@@ -44,9 +45,7 @@ public static ObjectDisposeResult Dispose(this GameObject? gameObject, bool forc | |
|
||
if (Application.isPlaying) | ||
{ | ||
#pragma warning disable COIMBRA0008 | ||
Object.Destroy(gameObject); | ||
#pragma warning restore COIMBRA0008 | ||
} | ||
else | ||
{ | ||
|
@@ -125,9 +124,7 @@ public static ObjectDisposeResult Dispose(this Object o, bool forceDestroy) | |
|
||
if (Application.isPlaying) | ||
{ | ||
#pragma warning disable COIMBRA0008 | ||
Object.Destroy(o); | ||
#pragma warning restore COIMBRA0008 | ||
} | ||
else | ||
{ | ||
Comment on lines
124
to
130
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
@@ -145,7 +142,9 @@ public static T GetValid<T>(this T o) | |
{ | ||
if (o is Object obj) | ||
{ | ||
#pragma warning disable CS8603 // Possible null reference return. | ||
return obj != null ? o : default; | ||
#pragma warning restore CS8603 // Possible null reference return. | ||
Comment on lines
+145
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The addition of the null reference check before returning the object is a good improvement. However, the use of Overall, the changes in Suggestions
Changes made to
|
||
} | ||
|
||
return o; | ||
Comment on lines
142
to
150
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The - #pragma warning disable CS8603 // Possible null reference return.
- return obj != null ? o : default;
- #pragma warning restore CS8603 // Possible null reference return.
+ return obj != null ? o : throw new ArgumentNullException(nameof(o)); |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
#nullable enable | ||
Comment on lines
4
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The However, it seems that the old code also had some other using directives ( Also, there is an extra space character at the beginning of line 4 in the new code. Please remove that space character. Here's the updated code: using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Text;
#nullable enable
namespace GameLovers Please ensure that the missing using directives are added and the extra space character is removed. |
||
// ReSharper disable once CheckNamespace | ||
|
||
namespace GameLovers | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,15 @@ | |
|
||
namespace GameLovers | ||
{ | ||
/// <summary> | ||
/// This object contains a pair of data. | ||
/// Use <see cref="StructPair{TKey, TValue}"/> if the container data is value types. | ||
/// | ||
/// Use this data structure if the container data is reference types, in order to | ||
/// improve memory usage performance. | ||
/// </summary> | ||
[Serializable] | ||
public struct Pair<TKey, TValue> | ||
public class Pair<TKey, TValue> | ||
Comment on lines
+8
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{ | ||
public TKey Key; | ||
public TValue Value; | ||
Comment on lines
+16
to
19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
@@ -22,6 +29,25 @@ public override string ToString() | |
return $"[{Key.ToString()},{Value.ToString()}]"; | ||
} | ||
} | ||
[Serializable] | ||
public struct StructPair<TKey, TValue> | ||
where TKey : struct | ||
where TValue : struct | ||
{ | ||
public TKey Key; | ||
public TValue Value; | ||
|
||
public StructPair(TKey key, TValue value) | ||
{ | ||
Key = key; | ||
Value = value; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return $"[{Key.ToString()},{Value.ToString()}]"; | ||
} | ||
} | ||
Comment on lines
+32
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A new To optimize memory usage, it's generally recommended to use structs instead of classes for small data structures that are frequently created and destroyed. However, using a class instead of a struct can be justified if there are specific requirements or design considerations. Consider the following points when reviewing this change:
Please review these changes and provide feedback accordingly. |
||
|
||
[Serializable] | ||
public struct Vector4Int | ||
|
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.
The code has been simplified by removing the
COIMBRA0008
pragma directives and using anif-else
statement instead. This change improves readability and removes unnecessary compiler warnings. However, it's important to note that theObject.Destroy
method should be used with caution, as it can lead to memory leaks if not properly managed. Make sure that all references to the destroyed object are properly cleaned up.