• Bryan C. Mills's avatar
    io/ioutil: don't cap buffer size in ReadFile · 1d07ed15
    Bryan C. Mills authored
    When we added a Stat call to determine the initial buffer size in
    https://golang.org/cl/163069, we included an arbitrary 1e9-byte limit
    "just in case". That interacts badly with power-of-2 resizing in
    *bytes.Buffer: it causes buffers reading from very large files to
    consume up to twice the necessary space.
    
    The documentation for (os.FileInfo).Size says that it reports "length
    in bytes for regular files; system-dependent for others", but the
    "system dependent" cases overwhelmingly return either a small number
    (e.g., the length of the target path for a symlink) or a non-positive
    number (e.g., for a file in /proc under Linux). It should be
    appropriate to use the number reported by Size as an approximate lower
    bound, even if it is large.
    
    fixes #21455
    
    Change-Id: I609c72519b7b87428c24d0b22db46eede30e0e54
    Reviewed-on: https://go-review.googlesource.com/55870Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    1d07ed15
Name
Last commit
Last update
..
ioutil Loading commit data...
example_test.go Loading commit data...
io.go Loading commit data...
io_test.go Loading commit data...
multi.go Loading commit data...
multi_test.go Loading commit data...
pipe.go Loading commit data...
pipe_test.go Loading commit data...