Remove regexp for comment detection

This commit is contained in:
Simon Eskildsen
2013-08-21 13:04:52 -04:00
parent 4f0eb93696
commit 1dadca892a
2 changed files with 3 additions and 8 deletions

View File

@@ -4,7 +4,6 @@ import (
"bufio" "bufio"
"fmt" "fmt"
"io" "io"
"regexp"
"math/rand" "math/rand"
"net/http" "net/http"
"os" "os"
@@ -31,7 +30,7 @@ func readTargets(source io.Reader) (Targets, error) {
for scanner.Scan() { for scanner.Scan() {
line := scanner.Text() line := scanner.Text()
if !skipLine(line) { // Not a comment or blank line if line = strings.TrimSpace(line); line != "" && line[0:2] != "//" { // A comment or blank line
lines = append(lines, line) lines = append(lines, line)
} }
} }
@@ -42,10 +41,6 @@ func readTargets(source io.Reader) (Targets, error) {
return NewTargets(lines) return NewTargets(lines)
} }
func skipLine(line string) (bool) {
return regexp.MustCompile(`^\s*((\/\/)|$)`).MatchString(line)
}
// NewTargets instantiates Targets from a slice of strings // NewTargets instantiates Targets from a slice of strings
func NewTargets(lines []string) (Targets, error) { func NewTargets(lines []string) (Targets, error) {
targets := make([]*http.Request, 0) targets := make([]*http.Request, 0)