diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-02-18 09:50:58 +0100 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-02-18 09:50:58 +0100 |
commit | c072558b90f1bbedc2022b0f30c8b1ac4712538e (patch) | |
tree | 67767591619e4bd8111fb05fac185cde94fb7378 /doc/htmlgen.go | |
parent | 5859517b767c99749a45651c15d4bae5520ebae8 (diff) | |
download | golang-c072558b90f1bbedc2022b0f30c8b1ac4712538e.tar.gz |
Imported Upstream version 2011.02.15upstream/2011.02.15
Diffstat (limited to 'doc/htmlgen.go')
-rw-r--r-- | doc/htmlgen.go | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/doc/htmlgen.go b/doc/htmlgen.go index 5d0bad8b5..4d68767c3 100644 --- a/doc/htmlgen.go +++ b/doc/htmlgen.go @@ -18,13 +18,13 @@ import ( ) var ( - lines = make([][]byte, 0, 10000) // assume big enough - linebuf = make([]byte, 10000) // assume big enough + lines = make([][]byte, 0, 2000) // probably big enough; grows if not empty = []byte("") newline = []byte("\n") tab = []byte("\t") quote = []byte(`"`) + indent = []byte{' ', ' ', ' ', ' '} sectionMarker = []byte("----\n") preStart = []byte("<pre>") @@ -52,9 +52,7 @@ func read() { if err != nil { log.Fatal(err) } - n := len(lines) - lines = lines[0 : n+1] - lines[n] = line + lines = append(lines, line) } } @@ -173,19 +171,7 @@ func trim(l []byte) []byte { return l } -// expand tabs to 4 spaces. don't worry about columns. +// expand tabs to spaces. don't worry about columns. func expandTabs(l []byte) []byte { - j := 0 // position in linebuf. - for _, c := range l { - if c == '\t' { - for k := 0; k < 4; k++ { - linebuf[j] = ' ' - j++ - } - } else { - linebuf[j] = c - j++ - } - } - return linebuf[0:j] + return bytes.Replace(l, tab, indent, -1) } |