Commit 71288891 authored by Albert Strasheim's avatar Albert Strasheim Committed by Adam Langley

crypto/rand: Added read buffer to speed up requests for small amounts of bytes.

R=agl1, rsc
CC=golang-dev
https://golang.org/cl/4170056
parent 00d8d005
......@@ -8,6 +8,7 @@
package rand
import (
"bufio"
"crypto/aes"
"io"
"os"
......@@ -23,7 +24,7 @@ func init() { Reader = &devReader{name: "/dev/urandom"} }
// A devReader satisfies reads by reading the file named name.
type devReader struct {
name string
f *os.File
f io.Reader
mu sync.Mutex
}
......@@ -35,7 +36,7 @@ func (r *devReader) Read(b []byte) (n int, err os.Error) {
if f == nil {
return 0, err
}
r.f = f
r.f = bufio.NewReader(f)
}
return r.f.Read(b)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment