-
Notifications
You must be signed in to change notification settings - Fork 447
Open
Description
Hey, I just noticed that the recursion here could be a simple loop, I think? (I'm new to Go, not new to programming.)
Lines 50 to 68 in 3fc4292
| func getStatementStart(src []byte) []byte { | |
| pos := indexOfNonSpaceChar(src) | |
| if pos == -1 { | |
| return nil | |
| } | |
| src = src[pos:] | |
| if src[0] != charComment { | |
| return src | |
| } | |
| // skip comment section | |
| pos = bytes.IndexFunc(src, isCharFunc('\n')) | |
| if pos == -1 { | |
| return nil | |
| } | |
| return getStatementStart(src[pos:]) | |
| } |
Could be something like this:
func getStatementStart(src []byte) []byte {
for {
pos := indexOfNonSpaceChar(src)
if pos == -1 {
return nil
}
src = src[pos:]
if src[0] != charComment {
return src
}
// skip comment section
pos = bytes.IndexFunc(src, isCharFunc('\n'))
if pos == -1 {
return nil
}
src = src[pos:]
}
}This is not a bug, just something I noticed while reading the source in order to understand exactly what syntax this tool is accepting. π
Sorry for the noise.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels