[squeak-dev] Re: The Trunk: Collections-HenrikSperreJohansen.335.mcz

Andreas Raab andreas.raab at gmx.de
Sun Mar 14 08:31:59 UTC 2010


On 3/13/2010 11:27 AM, Levente Uzonyi wrote:
> I had a different plan to attack this problem:

Go for it. This one was simple because it's basically just replacing 
nextPut: with nextPutAll: which is a no-brainer to me. If you've got 
something even better, that's even better! :-)

Cheers,
   - Andreas

>
> Installer squeak
> project: 'inbox';
> install: 'Multilingual-ul.102.mcz';
> install: 'Collections-ul.336.mcz'
>
> Benchmark:
>
> ((1 to: 10) detectSum: [ :run |
> |converter|
> converter := UTF8TextConverter new.
> [ 1 to: 50000 do: [ :index |
> 'abcaskjdhfáasiugbvsipruvnaséipvunasivunapiívunasieunó'
> convertToWithConverter: converter ] ] timeToRun ]) / 10.0
> "old ==> 355.6 new ==> 273.0"
>
>
> Levente
>
> On Sat, 13 Mar 2010, commits at source.squeak.org wrote:
>
>> Andreas Raab uploaded a new version of Collections to project The Trunk:
>> http://source.squeak.org/trunk/Collections-HenrikSperreJohansen.335.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Collections-HenrikSperreJohansen.335
>> Author: HenrikSperreJohansen
>> Time: 12 March 2010, 3:38:49.316 pm
>> UUID: 8b8f9b48-feb7-7d4d-9458-dcd334ad6e81
>> Ancestors: Collections-ar.334
>>
>> Faster String>>convertFromWithConverter: from Pharo.
>>
>> Useful in f.ex. asVMPathName.
>>
>> Test:
>>
>> [|converter|
>> converter := UTF8TextConverter new.
>> 1 to: 50000 do: [:ix |
>> 'abcćřĺaskjdhfasiugbvsipruvnasipvunasivunapivunasieun'
>> convertToWithConverter: converter]] timeToRun
>>
>> =============== Diff against Collections-ar.334 ===============
>>
>> Item was changed:
>> ----- Method: String>>convertToWithConverter: (in category
>> 'converting') -----
>> + convertToWithConverter: converter
>> + converter
>> + ifNil: [^ self].
>> + ^ String
>> + new: self size
>> + streamContents: [:writeStream |
>> - convertToWithConverter: converter
>> -
>> - converter ifNil: [ ^self ].
>> - ^String new: self size streamContents: [ :stream |
>> - | character |
>> - 1 to: self size do: [ :index |
>> converter
>> + nextPutAll: self toStream: writeStream;
>> + emitSequenceToResetStateIfNeededOn: writeStream]!
>> - nextPut: (self at: index)
>> - toStream: stream ].
>> - converter emitSequenceToResetStateIfNeededOn: stream ]!
>>
>>
>>
>
>
>




More information about the Squeak-dev mailing list