Skip to content

Commit 55e84fc

Browse files
committed
Fix InlineDictionary Behavior for Single Item Reassignment
Previous Behavior: - When the `Set` method was called, it ignored the `overwrite` parameter if the dictionary contained only one item. - This caused the `Set` method to behave like the `Add` method, leading to unexpected behavior in composition animations. - Specifically, the second composition animation would not play because it could not replace the first animation. Instead, it was added after the first animation, preventing it from being executed. Updated Behavior: - The `InlineDictionary` now respects the `overwrite` parameter even when it contains only one item. - This ensures that the second composition animation can overwrite the first one, allowing it to play correctly.
1 parent 68a626f commit 55e84fc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Avalonia.Base/Utilities/SmallDictionary.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@ void SetCore(TKey key, TValue value, bool overwrite)
7777
}
7878
else
7979
{
80-
// We have a single element, upgrade to array
80+
// We have a single element, check if we should update the value.
81+
if((TKey)_data == key && overwrite)
82+
{
83+
_data = key;
84+
_value = value;
85+
86+
return;
87+
}
88+
// If we do not replace it, upgrade to array.
8189
arr = new KeyValuePair[6];
8290
arr[0] = new KeyValuePair((TKey)_data, _value);
8391
arr[1] = new KeyValuePair(key, value);

0 commit comments

Comments
 (0)