Skip to content

Commit

Permalink
Merge pull request #39 from bkielbasa/readability-improvement
Browse files Browse the repository at this point in the history
small readability improvement
  • Loading branch information
matryer authored Mar 4, 2021
2 parents e7022e9 + ca53bc2 commit 86ebe5e
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 86ebe5e

Please sign in to comment.