Skip to content

Commit cf9e57b

Browse files
authored
Avoid some alloc by merging where and single (#2044)
1 parent 6d33829 commit cf9e57b

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

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)