Skip to content

Commit 86ebe5e

Browse files
authored
Merge pull request #39 from bkielbasa/readability-improvement
small readability improvement
2 parents e7022e9 + ca53bc2 commit 86ebe5e

File tree

1 file changed

+37
-34
lines changed

1 file changed

+37
-34
lines changed

is.go

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,19 @@ func loadComment(path string, line int) (string, bool) {
258258
s := bufio.NewScanner(f)
259259
i := 1
260260
for s.Scan() {
261-
if i == line {
262-
text := s.Text()
263-
commentI := strings.Index(text, "// ")
264-
if commentI == -1 {
265-
return "", false // no comment
266-
}
267-
text = text[commentI+2:]
268-
text = strings.TrimSpace(text)
269-
return text, true
261+
if i != line {
262+
i++
263+
continue
264+
}
265+
266+
text := s.Text()
267+
commentI := strings.Index(text, "// ")
268+
if commentI == -1 {
269+
return "", false // no comment
270270
}
271-
i++
271+
text = text[commentI+2:]
272+
text = strings.TrimSpace(text)
273+
return text, true
272274
}
273275
return "", false
274276
}
@@ -284,33 +286,34 @@ func loadArguments(path string, line int) (string, bool) {
284286
s := bufio.NewScanner(f)
285287
i := 1
286288
for s.Scan() {
287-
if i == line {
288-
text := s.Text()
289-
braceI := strings.Index(text, "(")
290-
if braceI == -1 {
291-
return "", false
289+
if i != line {
290+
i++
291+
continue
292+
}
293+
text := s.Text()
294+
braceI := strings.Index(text, "(")
295+
if braceI == -1 {
296+
return "", false
297+
}
298+
text = text[braceI+1:]
299+
cs := bufio.NewScanner(strings.NewReader(text))
300+
cs.Split(bufio.ScanBytes)
301+
j := 0
302+
c := 1
303+
for cs.Scan() {
304+
switch cs.Text() {
305+
case ")":
306+
c--
307+
case "(":
308+
c++
292309
}
293-
text = text[braceI+1:]
294-
cs := bufio.NewScanner(strings.NewReader(text))
295-
cs.Split(bufio.ScanBytes)
296-
j := 0
297-
c := 1
298-
for cs.Scan() {
299-
switch cs.Text() {
300-
case ")":
301-
c--
302-
case "(":
303-
c++
304-
}
305-
if c == 0 {
306-
break
307-
}
308-
j++
310+
if c == 0 {
311+
break
309312
}
310-
text = text[:j]
311-
return text, true
313+
j++
312314
}
313-
i++
315+
text = text[:j]
316+
return text, true
314317
}
315318
return "", false
316319
}

0 commit comments

Comments
 (0)