aboutsummaryrefslogtreecommitdiff
path: root/Sources/WmapParser
diff options
context:
space:
mode:
authorRuben Beltran del Rio <jj@r.bdr.sh>2025-12-15 11:30:47 +0100
committerRuben Beltran del Rio <jj@r.bdr.sh>2025-12-15 11:51:49 +0100
commitfabd59b7d1540900bd64590646c73c917706ecd8 (patch)
tree6e4e6e56aea797917f0613ed135f4fd1c834a674 /Sources/WmapParser
parent969b6a6653699b9f8662feb7f42511740f96f84a (diff)
Increase coverage of testsHEADmain
Diffstat (limited to 'Sources/WmapParser')
-rw-r--r--Sources/WmapParser/ComponentParser.swift3
-rw-r--r--Sources/WmapParser/DependencyParser.swift8
-rw-r--r--Sources/WmapParser/Utils.swift3
3 files changed, 7 insertions, 7 deletions
diff --git a/Sources/WmapParser/ComponentParser.swift b/Sources/WmapParser/ComponentParser.swift
index 79f5493..d87abc5 100644
--- a/Sources/WmapParser/ComponentParser.swift
+++ b/Sources/WmapParser/ComponentParser.swift
@@ -1,6 +1,7 @@
extension WmapParser {
- /// Parses a component with its coordinates.
+ /// Parses a component with its coordinates. Assumes a trimmed line was
+ /// provided.
static func parseComponent<T: Collection>(_ bytes: T, _ start: Int, _ end: Int) -> Component?
where T.Element == UInt8, T.Index == Int {
guard let (label, parenthesisIndex) = extractComponentLabel(bytes, start, end) else {
diff --git a/Sources/WmapParser/DependencyParser.swift b/Sources/WmapParser/DependencyParser.swift
index 2567bfe..45408d5 100644
--- a/Sources/WmapParser/DependencyParser.swift
+++ b/Sources/WmapParser/DependencyParser.swift
@@ -22,9 +22,7 @@ extension WmapParser {
)
-> Dependency?
where T.Element == UInt8, T.Index == Int {
- guard let isDirected = extractIsDirected(bytes, separatorIndex, end) else {
- return nil
- }
+ let isDirected = extractIsDirected(bytes, separatorIndex, end)
guard let fromComponent = extractTrimmedString(bytes, start, separatorIndex) else {
return nil
@@ -45,10 +43,10 @@ extension WmapParser {
private static func extractIsDirected<T: Collection>(
_ bytes: T, _ separatorIndex: Int, _ end: Int
)
- -> Bool?
+ -> Bool
where T.Element == UInt8, T.Index == Int {
let followingCharacter = separatorIndex + 1
- guard followingCharacter < end else { return nil }
+ guard followingCharacter < end else { return false }
if bytes[followingCharacter] == kGreaterThan {
return true
}
diff --git a/Sources/WmapParser/Utils.swift b/Sources/WmapParser/Utils.swift
index 4886eb3..e88b072 100644
--- a/Sources/WmapParser/Utils.swift
+++ b/Sources/WmapParser/Utils.swift
@@ -96,7 +96,8 @@ extension WmapParser {
return index
}
- /// Given the bytes buffer, finds the next non-empty line.
+ /// Given the bytes buffer, finds the next non-empty line without leading.
+ /// or trailing whitespace.
@inline(__always)
static func extractLine<T: Collection>(_ bytes: T, _ index: inout Int, _ length: Int) -> (
Int, Int