From 75cd0c848ff1a57a6fa90b79eef180e7a33b0a42 Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 30 Mar 2012 22:09:55 +0000 Subject: libgo: Update to weekly.2012-03-22. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186026 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgo/go/io/ioutil/ioutil.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libgo/go/io') diff --git a/libgo/go/io/ioutil/ioutil.go b/libgo/go/io/ioutil/ioutil.go index 180afc2c221..f072b8c754a 100644 --- a/libgo/go/io/ioutil/ioutil.go +++ b/libgo/go/io/ioutil/ioutil.go @@ -53,10 +53,13 @@ func ReadFile(filename string) ([]byte, error) { defer f.Close() // It's a good but not certain bet that FileInfo will tell us exactly how much to // read, so let's try it but be prepared for the answer to be wrong. - fi, err := f.Stat() var n int64 - if size := fi.Size(); err == nil && size < 2e9 { // Don't preallocate a huge buffer, just in case. - n = size + + if fi, err := f.Stat(); err == nil { + // Don't preallocate a huge buffer, just in case. + if size := fi.Size(); size < 1e9 { + n = size + } } // As initial capacity for readAll, use n + a little extra in case Size is zero, // and to avoid another allocation after Read has filled the buffer. The readAll -- cgit v1.2.1