Skip to content

Commit 4775582

Browse files
committed
Use .first(where:)
Modern Swift ...
1 parent a144a31 commit 4775582

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Sources/ZeeQL/Access/Entity.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,16 @@ public extension Entity { // default imp
197197

198198
@inlinable
199199
subscript(attribute n: String) -> Attribute? {
200-
for attr in attributes { if attr.name == n { return attr } }
201-
return nil
200+
attributes.first(where: { $0.name == n })
202201
}
203202
@inlinable
204203
subscript(columnName n: String) -> Attribute? {
205-
for attr in attributes { if attr.columnName == n { return attr } }
206-
return nil
204+
attributes.first(where: { $0.columnName == n })
207205
}
208206

209207
@inlinable
210208
subscript(relationship n: String) -> Relationship? {
211-
for rel in relationships { if rel.name == n { return rel } }
212-
return nil
209+
relationships.first(where: { $0.name == n })
213210
}
214211

215212
@inlinable

0 commit comments

Comments
 (0)