-
-
Notifications
You must be signed in to change notification settings - Fork 485
Minor optimizations and cleaning #1484
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -2,14 +2,7 @@ | |
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using System.Collections.Concurrent; | ||
| using System.Collections.Generic; | ||
| using System.Collections.Immutable; | ||
| using System.Linq; | ||
| using System.Runtime.CompilerServices; | ||
| using KGySoft.CoreLibraries; | ||
| using StabilityMatrix.Core.Helper.Cache; | ||
|
|
||
| namespace StabilityMatrix.Avalonia.Controls.VendorLabs.Cache; | ||
|
|
||
|
|
@@ -23,7 +16,7 @@ public class InMemoryStorage<T> | |
| private readonly LinkedList<InMemoryStorageItem<T>> _lruList = []; | ||
|
|
||
| private int _maxItemCount; | ||
| private object _settingMaxItemCountLocker = new(); | ||
| private readonly Lock _settingMaxItemCountLocker = new(); | ||
|
Contributor
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 type of private readonly object _settingMaxItemCountLocker = new(); |
||
|
|
||
| /// <summary> | ||
| /// Gets or sets the maximum count of Items that can be stored in this InMemoryStorage instance. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,4 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using StabilityMatrix.Core.Extensions; | ||
| using StabilityMatrix.Core.Extensions; | ||
| using StabilityMatrix.Core.Models; | ||
| using StabilityMatrix.Core.Models.Api; | ||
|
|
||
|
|
@@ -10,22 +7,22 @@ namespace StabilityMatrix.Avalonia.Helpers; | |
| public static class EnumHelpers | ||
| { | ||
| public static IEnumerable<CivitPeriod> AllCivitPeriods { get; } = | ||
| Enum.GetValues(typeof(CivitPeriod)).Cast<CivitPeriod>(); | ||
| Enum.GetValues<CivitPeriod>().Cast<CivitPeriod>(); | ||
|
Contributor
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 static IEnumerable<CivitSortMode> AllSortModes { get; } = | ||
| Enum.GetValues(typeof(CivitSortMode)).Cast<CivitSortMode>(); | ||
| Enum.GetValues<CivitSortMode>().Cast<CivitSortMode>(); | ||
|
Contributor
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 static IEnumerable<CivitModelType> AllCivitModelTypes { get; } = | ||
| Enum.GetValues(typeof(CivitModelType)) | ||
| Enum.GetValues<CivitModelType>() | ||
| .Cast<CivitModelType>() | ||
| .Where(t => t == CivitModelType.All || t.ConvertTo<SharedFolderType>() > 0) | ||
| .OrderBy(t => t.ToString()); | ||
|
|
||
| public static IEnumerable<CivitModelType> MetadataEditorCivitModelTypes { get; } = | ||
| Enum.GetValues(typeof(CivitModelType)).Cast<CivitModelType>().OrderBy(t => t.ToString()); | ||
| Enum.GetValues<CivitModelType>().Cast<CivitModelType>().OrderBy(t => t.ToString()); | ||
|
Contributor
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 static IEnumerable<CivitBaseModelType> AllCivitBaseModelTypes { get; } = | ||
| Enum.GetValues(typeof(CivitBaseModelType)).Cast<CivitBaseModelType>(); | ||
| Enum.GetValues<CivitBaseModelType>().Cast<CivitBaseModelType>(); | ||
|
Comment on lines
9
to
+25
Contributor
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 public static IEnumerable<CivitPeriod> AllCivitPeriods { get; } =
Enum.GetValues<CivitPeriod>();
public static IEnumerable<CivitSortMode> AllSortModes { get; } =
Enum.GetValues<CivitSortMode>();
public static IEnumerable<CivitModelType> AllCivitModelTypes { get; } =
Enum.GetValues<CivitModelType>()
.Where(t => t == CivitModelType.All || t.ConvertTo<SharedFolderType>() > 0)
.OrderBy(t => t.ToString());
public static IEnumerable<CivitModelType> MetadataEditorCivitModelTypes { get; } =
Enum.GetValues<CivitModelType>().OrderBy(t => t.ToString());
public static IEnumerable<CivitBaseModelType> AllCivitBaseModelTypes { get; } =
Enum.GetValues<CivitBaseModelType>();
Contributor
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 static IEnumerable<CivitBaseModelType> MetadataEditorCivitBaseModelTypes { get; } = | ||
| AllCivitBaseModelTypes.Where(x => x != CivitBaseModelType.All); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ public static partial class HardwareHelper | |
| private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); | ||
|
|
||
| private static IReadOnlyList<GpuInfo>? cachedGpuInfos; | ||
| private static readonly object cachedGpuInfosLock = new(); | ||
| private static readonly Lock cachedGpuInfosLock = new(); | ||
|
Contributor
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 type of private static readonly object cachedGpuInfosLock = new(); |
||
|
|
||
| private static readonly Lazy<IHardwareInfo> HardwareInfoLazy = new(() => new Hardware.Info.HardwareInfo() | ||
| ); | ||
|
|
||
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
using System.Collections.Generic;statement was removed, but this file usesDictionary<TKey, TValue>andLinkedList<T>, which are defined in that namespace. This will likely cause a compilation error unlessSystem.Collections.Genericis included as a global using for the project. If it's not a global using, this statement should be restored.