Skip to content

Commit 356a4ee

Browse files
committed
NameBuilder: no StringBuilder, string intepolation is faster
Intepolation is faster in this case and consumes less resources
1 parent a2a8701 commit 356a4ee

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -385,27 +385,20 @@ public string BuildIndexName(TypeInfo type, IndexInfo index)
385385
}
386386

387387
if (index.IsVirtual) {
388-
var sb = new StringBuilder(result, result.Length + 12 + type.Name.Length);
389-
390388
var indexAttributes = index.Attributes;
391-
if (indexAttributes.HasFlag(IndexAttributes.Filtered)) {
392-
sb.Append(".FILTERED.");
393-
}
394-
else if (indexAttributes.HasFlag(IndexAttributes.Join)) {
395-
sb.Append(".JOIN.");
396-
}
397-
else if (indexAttributes.HasFlag(IndexAttributes.Union)) {
398-
sb.Append(".UNION.");
399-
}
400-
else if (indexAttributes.HasFlag(IndexAttributes.View)) {
401-
sb.Append(".VIEW.");
402-
}
403-
else if (indexAttributes.HasFlag(IndexAttributes.Typed)) {
404-
sb.Append(".TYPED.");
405-
}
406389

407-
sb.Append(type.Name);
408-
result = sb.ToString();
390+
var indexNameBeforeRules = indexAttributes.HasFlag(IndexAttributes.Filtered)
391+
? $"{result}.FILTERED.{type.Name}"
392+
: indexAttributes.HasFlag(IndexAttributes.Join)
393+
? $"{result}.JOIN.{type.Name}"
394+
: indexAttributes.HasFlag(IndexAttributes.Union)
395+
? $"{result}.UNION.{type.Name}"
396+
: indexAttributes.HasFlag(IndexAttributes.View)
397+
? $"{result}.VIEW.{type.Name}"
398+
: indexAttributes.HasFlag(IndexAttributes.Typed)
399+
? $"{result}.TYPED.{type.Name}"
400+
: $"{result}{type.Name}";
401+
return ApplyNamingRules(indexNameBeforeRules);
409402
}
410403
return ApplyNamingRules(result);
411404
}

0 commit comments

Comments
 (0)