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

Side by Side Diff: src/compress/gzip/gunzip.go

Issue 97140043: code review 97140043: compress/flate: add Reset() to allow reusing large buffers to compress multipl
Patch Set: diff -r e1a081e6ddf8a77b267eb0d2b9747b2181524106 https://code.google.com/p/go Created 9 years, 6 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:
View unified diff | Download patch
OLDNEW
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 if err != nil { 200 if err != nil {
201 return err 201 return err
202 } 202 }
203 sum := z.digest.Sum32() & 0xFFFF 203 sum := z.digest.Sum32() & 0xFFFF
204 if n != sum { 204 if n != sum {
205 return ErrHeader 205 return ErrHeader
206 } 206 }
207 } 207 }
208 208
209 z.digest.Reset() 209 z.digest.Reset()
210 » z.decompressor = flate.NewReader(z.r) 210 » if z.decompressor == nil {
211 » » z.decompressor = flate.NewReader(z.r)
212 » } else {
213 » » z.decompressor.(flate.Resettable).Reset(z.r, nil)
kortschak 2014/09/30 12:09:44 s/Resettable/Resetter/
214 » }
211 return nil 215 return nil
212 } 216 }
213 217
214 func (z *Reader) Read(p []byte) (n int, err error) { 218 func (z *Reader) Read(p []byte) (n int, err error) {
215 if z.err != nil { 219 if z.err != nil {
216 return 0, z.err 220 return 0, z.err
217 } 221 }
218 if len(p) == 0 { 222 if len(p) == 0 {
219 return 0, nil 223 return 0, nil
220 } 224 }
(...skipping 25 matching lines...) Expand all
246 } 250 }
247 251
248 // Yes. Reset and read from it. 252 // Yes. Reset and read from it.
249 z.digest.Reset() 253 z.digest.Reset()
250 z.size = 0 254 z.size = 0
251 return z.Read(p) 255 return z.Read(p)
252 } 256 }
253 257
254 // Close closes the Reader. It does not close the underlying io.Reader. 258 // Close closes the Reader. It does not close the underlying io.Reader.
255 func (z *Reader) Close() error { return z.decompressor.Close() } 259 func (z *Reader) Close() error { return z.decompressor.Close() }
OLDNEW

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