Skip to content

Commit 519892b

Browse files
committed
Merge branch 'improvement/SetValue-no-update' into release/5.1.0
If calling `TrackedRecordCollection<>.SetValue()` without any updates—i.e., an existing record is present, but the `Value` hasn't changed, and neither `markDirty` nor `version` are specified—then return without further processing. In that case, there's no need to create a new instance of the record, to potentially call the property on the corresponding `Topic`, or to store the new record in the collection. This is a minor performance enhancement.
2 parents 3cf5ab0 + 589ee85 commit 519892b

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

OnTopic/Collections/Specialized/TrackedRecordCollection{TItem,TValue,TAttribute}.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ internal void SetValue(
461461
else if (originalItem.Value != value) {
462462
markAsDirty = true;
463463
}
464+
else if (!version.HasValue) {
465+
return;
466+
}
464467
updatedItem = originalItem with {
465468
Value = value,
466469
IsDirty = markAsDirty,

0 commit comments

Comments
 (0)