Skip to content

Commit 8f80333

Browse files
committed
Reorder GetValue() based on how common each condition is
Previously, `GetValue()` was ordered according to popularity (with the exception of the compatibility check, which must come first). These were recently reordered to make sure that the fastest calls were placed upfront, thus preventing lookups when they weren't needed (565fa6f). With the caching of `IsList` and `IsConvertible` (d0fb8a4), however, that is no longer a concern. As such, we can return to prioritizing based on how common each is, thus reducing the number of conditions each property (or parameter) must be considered for.
1 parent 83d5c3d commit 8f80333

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

OnTopic/Mapping/TopicMappingService.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -525,20 +525,20 @@ await MapAsync(
525525
if (TryGetCompatibleProperty(source, targetType, configuration, out var compatibleValue)) {
526526
value = compatibleValue;
527527
}
528-
else if (configuration.MapToParent) {
528+
else if (configuration.Metadata.IsConvertible) {
529+
if (!mapAssociationsOnly) {
530+
value = GetScalarValue(source, configuration);
531+
}
532+
}
533+
else if (configuration.Metadata.IsList) {
529534
return null;
530535
}
531536
else if (configuration.AttributeKey is "Parent") {
532537
if (associations.HasFlag(AssociationTypes.Parents) && source.Parent is not null) {
533538
value = await GetTopicReferenceAsync(source.Parent, targetType, configuration, cache).ConfigureAwait(false);
534539
}
535540
}
536-
else if (configuration.Metadata.IsConvertible) {
537-
if (!mapAssociationsOnly) {
538-
value = GetScalarValue(source, configuration);
539-
}
540-
}
541-
else if (configuration.Metadata.IsList) {
541+
else if (configuration.MapToParent) {
542542
return null;
543543
}
544544
else if (configuration.Metadata.Type.IsClass && associations.HasFlag(AssociationTypes.References)) {

0 commit comments

Comments
 (0)