Skip to content

Commit 9f1f677

Browse files
committed
Ensure IsConvertible() isn't checked for IsList() or getTopicReference()
Previously, the `IsConvertible()` check was bypassed if `mapAssociationsOnly` was set. That makes sense, because there's no need to call `GetScalarValue()` in that case. Except that also necessitated that each of the subsequent conditions be checked, which collectively are more expensive than the check to `IsConvertible()`. As such, since scalar values are the most common type of property we're working with, it's cheaper to put this upfront and then check `mapAssociationsOnly` within it instead.
1 parent 07094e5 commit 9f1f677

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

OnTopic/Mapping/TopicMappingService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,10 @@ await MapAsync(
540540
value = await GetTopicReferenceAsync(source.Parent, targetType, configuration, cache).ConfigureAwait(false);
541541
}
542542
}
543-
else if (!mapAssociationsOnly && AttributeValueConverter.IsConvertible(targetType)) {
544-
value = GetScalarValue(source, configuration);
543+
else if (AttributeValueConverter.IsConvertible(targetType)) {
544+
if (!mapAssociationsOnly) {
545+
value = GetScalarValue(source, configuration);
546+
}
545547
}
546548
else if (IsList(targetType)) {
547549
return null;

0 commit comments

Comments
 (0)