aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/io
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-03-30 22:09:55 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-03-30 22:09:55 +0000
commit9a18821cfc7169ea9f4d0bb661e7c4ea362e993d (patch)
tree26322d11da7cc220190e0b8430565ea207eb3eab /libgo/go/io
parent57c7433fdc3fcb7b0cfd7b13bd11360a5e17c624 (diff)
downloadgcc-9a18821cfc7169ea9f4d0bb661e7c4ea362e993d.zip
gcc-9a18821cfc7169ea9f4d0bb661e7c4ea362e993d.tar.gz
gcc-9a18821cfc7169ea9f4d0bb661e7c4ea362e993d.tar.bz2
libgo: Update to weekly.2012-03-22.
From-SVN: r186026
Diffstat (limited to 'libgo/go/io')
-rw-r--r--libgo/go/io/ioutil/ioutil.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/libgo/go/io/ioutil/ioutil.go b/libgo/go/io/ioutil/ioutil.go
index 180afc2..f072b8c 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