]> Cypherpunks repositories - gostls13.git/commitdiff
test/bench: dead code in reverse-complement
authorRuss Cox <rsc@golang.org>
Sat, 5 Dec 2009 03:25:25 +0000 (19:25 -0800)
committerRuss Cox <rsc@golang.org>
Sat, 5 Dec 2009 03:25:25 +0000 (19:25 -0800)
R=r
https://golang.org/cl/165065

test/bench/reverse-complement.go

index c8a525bc9a21092f2adf0588910a18bdb245bc81..60e14dba8c140b19208fb0eb2acd0c47d705e5c6 100644 (file)
@@ -61,37 +61,8 @@ var complement = [256]uint8{
        'N': 'N', 'n': 'N',
 }
 
-var in *bufio.Reader
-
-func reverseComplement(in []byte) []byte {
-       outLen := len(in) + (len(in)+lineSize-1)/lineSize;
-       out := make([]byte, outLen);
-       j := 0;
-       k := 0;
-       for i := len(in) - 1; i >= 0; i-- {
-               if k == lineSize {
-                       out[j] = '\n';
-                       j++;
-                       k = 0;
-               }
-               out[j] = complement[in[i]];
-               j++;
-               k++;
-       }
-       out[j] = '\n';
-       j++;
-       return out[0:j];
-}
-
-func output(buf []byte) {
-       if len(buf) == 0 {
-               return
-       }
-       os.Stdout.Write(reverseComplement(buf));
-}
-
 func main() {
-       in = bufio.NewReader(os.Stdin);
+       in := bufio.NewReader(os.Stdin);
        buf := make([]byte, 1024*1024);
        line, err := in.ReadSlice('\n');
        for err == nil {
@@ -113,6 +84,8 @@ func main() {
                                w += len(nbuf) - len(buf);
                                buf = nbuf;
                        }
+
+                       // This loop is the bottleneck.
                        for r := 0; r < len(line); r++ {
                                w--;
                                buf[w] = complement[line[r]];