Skip to content

Commit

Permalink
small readability improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartłomiej Klimczak committed Feb 11, 2021
1 parent e7022e9 commit ca53bc2
Showing 1 changed file with 37 additions and 34 deletions.
71 changes: 37 additions & 34 deletions is.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,19 @@ func loadComment(path string, line int) (string, bool) {
s := bufio.NewScanner(f)
i := 1
for s.Scan() {
if i == line {
text := s.Text()
commentI := strings.Index(text, "// ")
if commentI == -1 {
return "", false // no comment
}
text = text[commentI+2:]
text = strings.TrimSpace(text)
return text, true
if i != line {
i++
continue
}

text := s.Text()
commentI := strings.Index(text, "// ")
if commentI == -1 {
return "", false // no comment
}
i++
text = text[commentI+2:]
text = strings.TrimSpace(text)
return text, true
}
return "", false
}
Expand All @@ -284,33 +286,34 @@ func loadArguments(path string, line int) (string, bool) {
s := bufio.NewScanner(f)
i := 1
for s.Scan() {
if i == line {
text := s.Text()
braceI := strings.Index(text, "(")
if braceI == -1 {
return "", false
if i != line {
i++
continue
}
text := s.Text()
braceI := strings.Index(text, "(")
if braceI == -1 {
return "", false
}
text = text[braceI+1:]
cs := bufio.NewScanner(strings.NewReader(text))
cs.Split(bufio.ScanBytes)
j := 0
c := 1
for cs.Scan() {
switch cs.Text() {
case ")":
c--
case "(":
c++
}
text = text[braceI+1:]
cs := bufio.NewScanner(strings.NewReader(text))
cs.Split(bufio.ScanBytes)
j := 0
c := 1
for cs.Scan() {
switch cs.Text() {
case ")":
c--
case "(":
c++
}
if c == 0 {
break
}
j++
if c == 0 {
break
}
text = text[:j]
return text, true
j++
}
i++
text = text[:j]
return text, true
}
return "", false
}
Expand Down

0 comments on commit ca53bc2

Please sign in to comment.