Skip to content

Commit 6a4e3d5

Browse files
committed
avoid some alloc by merging where and single
1 parent 40ad85b commit 6a4e3d5

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/DocumentFormat.OpenXml.Framework/Validation/Semantic/RelationshipTypeConstraint.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ public RelationshipTypeConstraint(OpenXmlQualifiedName attribute, string type)
6363
else
6464
{
6565
var pair = current.Part.Parts
66-
.Where(p => p.RelationshipId == attribute.Value.InnerText)
67-
.SingleOrDefault();
66+
.SingleOrDefault(p => p.RelationshipId == attribute.Value.InnerText);
6867

6968
if (pair is { })
7069
{

src/DocumentFormat.OpenXml.Framework/Validation/Semantic/SemanticConstraint.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ private static void Get(ValidationContext context, out SemanticValidationLevel l
131131
{
132132
return current.Package
133133
.GetAllParts()
134-
.Where(p => p.Parts.Any(r => r.OpenXmlPart.PackagePart.Uri == current.Part.PackagePart.Uri))
135-
.First();
134+
.First(p => p.Parts.Any(r => r.OpenXmlPart.PackagePart.Uri == current.Part.PackagePart.Uri));
136135
}
137136
else
138137
{

0 commit comments

Comments
 (0)