summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCasey Robinson <casey.robinson@distilnetworks.com>2014-12-18 20:49:15 -0500
committerCasey Robinson <casey.robinson@distilnetworks.com>2014-12-18 20:49:15 -0500
commit4d043382aa6faa118798dd6c3eceb73cb6bd2ba1 (patch)
tree1740b6e375c0d19c205fa03915d2b02361ed822b
parent2b934309a920df5cfdae47c923bf2222d926b442 (diff)
downloadonetime-4d043382aa6faa118798dd6c3eceb73cb6bd2ba1.tar.gz
onetime-4d043382aa6faa118798dd6c3eceb73cb6bd2ba1.tar.bz2
onetime-4d043382aa6faa118798dd6c3eceb73cb6bd2ba1.zip
only define up and clear once.
no need to rebuild every time through the loop.
-rw-r--r--main.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/main.go b/main.go
index cbc7912..dd4b20f 100644
--- a/main.go
+++ b/main.go
@@ -57,10 +57,6 @@ func main() {
}
}
-const (
- keyEscape = 27
-)
-
func parseStdin() ([]provider, int) {
nameLength := 0
bio := bufio.NewReader(os.Stdin)
@@ -122,9 +118,16 @@ func (d *display) update() {
}
}
+const (
+ keyEscape = 27
+)
+
+var (
+ up = []byte{keyEscape, '[', 'A'}
+ clear = []byte{keyEscape, '[', '2', 'K'}
+)
+
func (d *display) clear() {
- up := []byte{keyEscape, '[', 'A'}
- clear := []byte{keyEscape, '[', '2', 'K'}
for j := 0; j < len(d.ps); j++ {
os.Stdout.Write(clear)
os.Stdout.Write(up)