The Trunk: Compression-nice.13.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Compression-nice.13.mcz

commits-2
Nicolas Cellier uploaded a new version of Compression to project The Trunk:
http://source.squeak.org/trunk/Compression-nice.13.mcz

==================== Summary ====================

Name: Compression-nice.13
Author: nice
Time: 27 December 2009, 8:48:25 am
UUID: 4fd23945-a942-4ad2-a409-3718c24d23aa
Ancestors: Compression-nice.12

Cosmetic: move or remove a few temps inside closures

=============== Diff against Compression-nice.12 ===============

Item was changed:
  ----- Method: ZipArchive>>readMembersFrom:named: (in category 'private') -----
  readMembersFrom: stream named: fileName
- | newMember signature |
  [
+ | newMember signature |
  newMember := self memberClass newFromZipFile: stream named: fileName.
  signature := self readSignatureFrom: stream.
  signature = EndOfCentralDirectorySignature ifTrue: [ ^self ].
  signature = CentralDirectoryFileHeaderSignature
  ifFalse: [ self error: 'bad CD signature at ', (stream position - 4) printStringHex ].
  newMember readFrom: stream.
  newMember looksLikeDirectory ifTrue: [ newMember := newMember asDirectory ].
  self addMember: newMember.
  ] repeat.!

Item was changed:
  ----- Method: ZipArchive>>extractAllTo:informing:overwrite: (in category 'archive operations') -----
  extractAllTo: aDirectory informing: bar overwrite: allOverwrite
  "Extract all elements to the given directory"
+ | overwriteAll |
- | dir overwriteAll response |
  overwriteAll := allOverwrite.
+ self members do:[:entry| | dir |
- self members do:[:entry|
  entry isDirectory ifTrue:[
  bar ifNotNil:[bar value: 'Creating ', entry fileName].
  dir := (entry fileName findTokens:'/')
  inject: aDirectory into:[:base :part| base directoryNamed: part].
  dir assureExistence.
  ].
  ].
+ self members do:[:entry| | response |
- self members do:[:entry|
  entry isDirectory ifFalse:[
  bar ifNotNil:[bar value: 'Extracting ', entry fileName].
  response := entry extractInDirectory: aDirectory overwrite: overwriteAll.
  response == #retryWithOverwrite ifTrue:[
  overwriteAll := true.
  response := entry extractInDirectory: aDirectory overwrite: overwriteAll.
  ].
  response == #abort ifTrue:[^self].
  response == #failed ifTrue:[
  (self confirm: 'Failed to extract ', entry fileName, '. Proceed?') ifFalse:[^self].
  ].
  ].
  ].
  !

Item was changed:
  ----- Method: ZipFileMember>>uncompressDataTo: (in category 'private-writing') -----
  uncompressDataTo: aStream
 
+ | decoder buffer crcErrorMessage |
- | decoder buffer chunkSize crcErrorMessage |
  decoder := ZipReadStream on: stream.
  decoder expectedCrc: self crc32.
  buffer := ByteArray new: (32768 min: readDataRemaining).
  crcErrorMessage := nil.
 
  [[ readDataRemaining > 0 ] whileTrue: [
+ | chunkSize |
  chunkSize := 32768 min: readDataRemaining.
  buffer := decoder next: chunkSize into: buffer startingAt: 1.
  aStream next: chunkSize putAll: buffer startingAt: 1.
  readDataRemaining := readDataRemaining - chunkSize.
  ]] on: CRCError do: [ :ex | crcErrorMessage := ex messageText. ex proceed ].
 
  crcErrorMessage ifNotNil: [ self isCorrupt: true. CRCError signal: crcErrorMessage ]
 
  !

Item was changed:
  ----- Method: ZipWriteStream class>>regressionTestFrom:using:stats: (in category 'regression test') -----
  regressionTestFrom: fd using: tempName stats: stats
+ | files |
- | files file fullName |
  files := fd fileNames asSortedCollection.
+ files do:[:fName| | fullName file |
- files do:[:fName|
  file := nil.
  fullName := fd fullNameFor: fName.
  fullName = tempName ifFalse:[
  file := StandardFileStream new open: fullName forWrite: false].
  self compressAndDecompress: file using: tempName stats: stats].
  stats at: #numFiles put: (stats at: #numFiles ifAbsent:[0]) + files size.
  files := nil.
  self printRegressionStats: stats from: fd.
  fd directoryNames asSortedCollection do:[:dName|
  self regressionTestFrom: (fd directoryNamed: dName) using: tempName stats: stats.
  ].!