diff options
Diffstat (limited to 'Sources/WmapParser')
| -rw-r--r-- | Sources/WmapParser/ComponentParser.swift | 3 | ||||
| -rw-r--r-- | Sources/WmapParser/DependencyParser.swift | 8 | ||||
| -rw-r--r-- | Sources/WmapParser/Utils.swift | 3 |
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 |