Skip to content

Commit 43f0f16

Browse files
committed
perf: 优化性能减少一次 new
1 parent b9ef772 commit 43f0f16

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/BootstrapBlazor/Dynamic/DynamicObjectContext.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ public void AddAttribute(string columnName, Type attributeType, Type[] types, ob
4545
var attr = attributeType.GetConstructor(types);
4646
if (attr != null)
4747
{
48-
var cab = new CustomAttributeBuilder(attr, constructorArgs, namedProperties: propertyInfos ?? [], propertyValues: propertyValues ?? []);
49-
CustomerAttributeBuilderCache.AddOrUpdate(columnName, key => [cab], (key, builders) =>
48+
CustomerAttributeBuilderCache.AddOrUpdate(columnName, key => [CreateCustomAttributeBuilder()], (key, builders) =>
5049
{
51-
builders.Add(cab);
50+
builders.Add(CreateCustomAttributeBuilder());
5251
return builders;
5352
});
5453
}
54+
55+
CustomAttributeBuilder CreateCustomAttributeBuilder() => new(attr, constructorArgs, propertyInfos ?? [], propertyValues ?? []);
5556
}
5657

5758
/// <summary>

0 commit comments

Comments
 (0)