~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/io/ioutil/ioutil.go

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
        "io"
11
11
        "os"
12
12
        "sort"
 
13
        "sync"
13
14
)
14
15
 
15
16
// readAll reads from r until an error or EOF and returns the data it read
136
137
        return len(s), nil
137
138
}
138
139
 
 
140
var blackHolePool = sync.Pool{
 
141
        New: func() interface{} {
 
142
                b := make([]byte, 8192)
 
143
                return &b
 
144
        },
 
145
}
 
146
 
139
147
func (devNull) ReadFrom(r io.Reader) (n int64, err error) {
140
 
        buf := blackHole()
141
 
        defer blackHolePut(buf)
 
148
        bufp := blackHolePool.Get().(*[]byte)
142
149
        readSize := 0
143
150
        for {
144
 
                readSize, err = r.Read(buf)
 
151
                readSize, err = r.Read(*bufp)
145
152
                n += int64(readSize)
146
153
                if err != nil {
 
154
                        blackHolePool.Put(bufp)
147
155
                        if err == io.EOF {
148
156
                                return n, nil
149
157
                        }