Skip to content

Commit e24d66a

Browse files
MayankQuietMisdreavus
authored andcommitted
Refactored the lex function of the TrimmedLine in the BlockDirectiveParser
- Instead of incrementing the take count at every if conditions. We can increment at the end directly. - This make code concise and hence easier to read and debug the while loop.
1 parent 40f7f85 commit e24d66a

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

Sources/Markdown/Parser/BlockDirectiveParser.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -408,29 +408,21 @@ struct TrimmedLine {
408408
while let c = prefix.next() {
409409
if isEscaped {
410410
isEscaped = false
411-
takeCount += 1
412-
continue
413411
}
414-
if allowEscape,
412+
else if allowEscape,
415413
c == "\\" {
416414
isEscaped = true
417-
takeCount += 1
418-
continue
419415
}
420-
if isQuoted {
416+
else if isQuoted {
421417
if c == "\"" {
422418
isQuoted = false
423419
}
424-
takeCount += 1
425-
continue
426420
}
427-
if allowQuote,
421+
else if allowQuote,
428422
c == "\"" {
429423
isQuoted = true
430-
takeCount += 1
431-
continue
432424
}
433-
if case .stop = stop(c) {
425+
else if case .stop = stop(c) {
434426
break
435427
}
436428
takeCount += 1

0 commit comments

Comments
 (0)