Changed some formatting

This commit is contained in:
Linus Björnstam 2026-04-28 21:48:45 +02:00
parent a6e8ced7f7
commit b5b363ae9f
3 changed files with 23 additions and 19 deletions

View file

@ -10,9 +10,12 @@ namespace PersistentMap
// Public API // Public API
// --------------------------------------------------------- // ---------------------------------------------------------
/// <summary>TryGetValue tries to get the value at mapping key. If it finds the key it sets th
/// out var to value and returns true. </summary>
public static bool TryGetValue<K, V, TStrategy>(Node<K> root, K key, TStrategy strategy, out V value) public static bool TryGetValue<K, V, TStrategy>(Node<K> root, K key, TStrategy strategy, out V value)
where TStrategy : IKeyStrategy<K> where TStrategy : IKeyStrategy<K>
{ {
// We always get a strategy to avoid branching already here
long keyPrefix = strategy.UsesPrefixes ? strategy.GetPrefix(key) : 0; long keyPrefix = strategy.UsesPrefixes ? strategy.GetPrefix(key) : 0;
Node<K> current = root; Node<K> current = root;
@ -43,6 +46,7 @@ namespace PersistentMap
{ {
root = root.EnsureEditable(owner); root = root.EnsureEditable(owner);
// Todo, this should really be made a tuple return value to not stress the GC
var splitResult = InsertRecursive(root, key, value, strategy, owner, out countChanged); var splitResult = InsertRecursive(root, key, value, strategy, owner, out countChanged);
if (splitResult != null) if (splitResult != null)