The Trunk: Compression-nice.15.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.15.mcz

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

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

Name: Compression-nice.15
Author: nice
Time: 16 March 2010, 10:59:48.888 pm
UUID: aa871a89-0903-c147-a7e8-6dec1ee2f506
Ancestors: Compression-nice.14

Reverse the logic and avoid a copy:
- let next:putAll:startingAt: do the real work
- let nextPutAll: call next:putAll:startingAt:
This costs an additional send in nextPutAll: but is much better.

=============== Diff against Compression-nice.14 ===============

Item was changed:
  ----- Method: DeflateStream>>nextPutAll: (in category 'accessing') -----
  nextPutAll: aCollection
+ ^self next: aCollection size putAll: aCollection startingAt: 1!
- | start count max |
- aCollection species = collection species
- ifFalse:[
- aCollection do:[:ch| self nextPut: ch].
- ^aCollection].
- start := 1.
- count := aCollection size.
- [count = 0] whileFalse:[
- position = writeLimit ifTrue:[self deflateBlock].
- max := writeLimit - position.
- max > count ifTrue:[max := count].
- collection replaceFrom: position+1
- to: position+max
- with: aCollection
- startingAt: start.
- start := start + max.
- count := count - max.
- position := position + max].
- ^aCollection!

Item was changed:
  ----- Method: DeflateStream>>next:putAll:startingAt: (in category 'accessing') -----
+ next: bytesCount putAll: aCollection startingAt: startIndex
+ | start count max |
+ aCollection species = collection species
+ ifFalse:[
+ aCollection do:[:ch| self nextPut: ch].
+ ^aCollection].
+ start := startIndex.
+ count := bytesCount.
+ [count = 0] whileFalse:[
+ position = writeLimit ifTrue:[self deflateBlock].
+ max := writeLimit - position.
+ max > count ifTrue:[max := count].
+ collection replaceFrom: position+1
+ to: position+max
+ with: aCollection
+ startingAt: start.
+ start := start + max.
+ count := count - max.
+ position := position + max].
+ ^aCollection!
- next: bytes putAll: aCollection startingAt: startPos
- (startPos = 1 and:[bytes = aCollection size])
- ifTrue:[^self nextPutAll: aCollection].
- ^self nextPutAll: (aCollection copyFrom: startPos to: startPos + bytes - 1)!