diff options
author | Berkan Diler <berkan.diler1@ingka.ikea.com> | 2022-12-27 20:27:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-27 20:27:11 +0100 |
commit | 0d3b82477ecbf7128340b6725a79413427c68748 (patch) | |
tree | 2d62c68e38a3c4c79ef7cc1d92700617a40e70ca /Ryujinx.Common/Collections/TreeDictionary.cs | |
parent | 470be03c2ff22346a1f0ae53fa25f53c4d1790b5 (diff) |
Use new ArgumentNullException and ObjectDisposedException throw-helper API (#4163)1.1.493
Diffstat (limited to 'Ryujinx.Common/Collections/TreeDictionary.cs')
-rw-r--r-- | Ryujinx.Common/Collections/TreeDictionary.cs | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/Ryujinx.Common/Collections/TreeDictionary.cs b/Ryujinx.Common/Collections/TreeDictionary.cs index a5a3b818..d118a30c 100644 --- a/Ryujinx.Common/Collections/TreeDictionary.cs +++ b/Ryujinx.Common/Collections/TreeDictionary.cs @@ -22,10 +22,7 @@ namespace Ryujinx.Common.Collections /// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception> public V Get(K key) { - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } + ArgumentNullException.ThrowIfNull(key); Node<K, V> node = GetNode(key); @@ -47,14 +44,8 @@ namespace Ryujinx.Common.Collections /// <exception cref="ArgumentNullException"><paramref name="key"/> or <paramref name="value"/> are null</exception> public void Add(K key, V value) { - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } - if (value == null) - { - throw new ArgumentNullException(nameof(value)); - } + ArgumentNullException.ThrowIfNull(key); + ArgumentNullException.ThrowIfNull(value); Insert(key, value); } @@ -66,10 +57,8 @@ namespace Ryujinx.Common.Collections /// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception> public void Remove(K key) { - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } + ArgumentNullException.ThrowIfNull(key); + if (Delete(key) != null) { Count--; @@ -217,10 +206,7 @@ namespace Ryujinx.Common.Collections /// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception> private Node<K, V> GetNode(K key) { - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } + ArgumentNullException.ThrowIfNull(key); Node<K, V> node = Root; while (node != null) @@ -370,10 +356,8 @@ namespace Ryujinx.Common.Collections /// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception> private Node<K, V> FloorNode(K key) { - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } + ArgumentNullException.ThrowIfNull(key); + Node<K, V> tmp = Root; while (tmp != null) @@ -424,10 +408,8 @@ namespace Ryujinx.Common.Collections /// <exception cref="ArgumentNullException"><paramref name="key"/> is null</exception> private Node<K, V> CeilingNode(K key) { - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } + ArgumentNullException.ThrowIfNull(key); + Node<K, V> tmp = Root; while (tmp != null) @@ -477,10 +459,8 @@ namespace Ryujinx.Common.Collections // Method descriptions are not provided as they are already included as part of the interface. public bool ContainsKey(K key) { - if (key == null) - { - throw new ArgumentNullException(nameof(key)); - } + ArgumentNullException.ThrowIfNull(key); + return GetNode(key) != null; } @@ -493,10 +473,8 @@ namespace Ryujinx.Common.Collections public bool TryGetValue(K key, [MaybeNullWhen(false)] out V value) { - if (null == key) - { - throw new ArgumentNullException(nameof(key)); - } + ArgumentNullException.ThrowIfNull(key); + Node<K, V> node = GetNode(key); value = node != null ? node.Value : default; return node != null; @@ -504,10 +482,7 @@ namespace Ryujinx.Common.Collections public void Add(KeyValuePair<K, V> item) { - if (item.Key == null) - { - throw new ArgumentNullException(nameof(item.Key)); - } + ArgumentNullException.ThrowIfNull(item.Key); Add(item.Key, item.Value); } |