Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(132)

Delta Between Two Patch Sets: src/compress/gzip/gunzip.go

Issue 97140043: code review 97140043: compress/flate: add Reset() to allow reusing large buffers to compress multipl
Left Patch Set: diff -r e1a081e6ddf8a77b267eb0d2b9747b2181524106 https://code.google.com/p/go Created 9 years, 5 months ago
Right Patch Set: diff -r b91b31b57771240403a02a9257fbf8f0c6ea5f09 https://code.google.com/p/go Created 9 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/compress/flate/inflate_test.go ('k') | src/compress/zlib/reader.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Package gzip implements reading and writing of gzip format compressed files, 5 // Package gzip implements reading and writing of gzip format compressed files,
6 // as specified in RFC 1952. 6 // as specified in RFC 1952.
7 package gzip 7 package gzip
8 8
9 import ( 9 import (
10 "bufio" 10 "bufio"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 r flate.Reader 70 r flate.Reader
71 decompressor io.ReadCloser 71 decompressor io.ReadCloser
72 digest hash.Hash32 72 digest hash.Hash32
73 size uint32 73 size uint32
74 flg byte 74 flg byte
75 buf [512]byte 75 buf [512]byte
76 err error 76 err error
77 } 77 }
78 78
79 // NewReader creates a new Reader reading the given reader. 79 // NewReader creates a new Reader reading the given reader.
80 // The implementation buffers input and may read more data than necessary from r . 80 // If r does not also implement io.ByteReader,
81 // the decompressor may read more data than necessary from r.
81 // It is the caller's responsibility to call Close on the Reader when done. 82 // It is the caller's responsibility to call Close on the Reader when done.
82 func NewReader(r io.Reader) (*Reader, error) { 83 func NewReader(r io.Reader) (*Reader, error) {
83 z := new(Reader) 84 z := new(Reader)
84 z.r = makeReader(r) 85 z.r = makeReader(r)
85 z.digest = crc32.NewIEEE() 86 z.digest = crc32.NewIEEE()
86 if err := z.readHeader(true); err != nil { 87 if err := z.readHeader(true); err != nil {
87 return nil, err 88 return nil, err
88 } 89 }
89 return z, nil 90 return z, nil
90 } 91 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 251 }
251 252
252 // Yes. Reset and read from it. 253 // Yes. Reset and read from it.
253 z.digest.Reset() 254 z.digest.Reset()
254 z.size = 0 255 z.size = 0
255 return z.Read(p) 256 return z.Read(p)
256 } 257 }
257 258
258 // Close closes the Reader. It does not close the underlying io.Reader. 259 // Close closes the Reader. It does not close the underlying io.Reader.
259 func (z *Reader) Close() error { return z.decompressor.Close() } 260 func (z *Reader) Close() error { return z.decompressor.Close() }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b