The Trunk: Files-nice.48.mcz

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

The Trunk: Files-nice.48.mcz

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

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

Name: Files-nice.48
Author: nice
Time: 7 December 2009, 8:13:37 am
UUID: d694d4c7-8bb3-9f41-bcaf-805c955c64d8
Ancestors: Files-ul.47

Restore the semantics of #readInto:startingAt:count: to return the number of bytes read

=============== Diff against Files-ul.47 ===============

Item was changed:
  ----- Method: StandardFileStream>>readInto:startingAt:count: (in category 'read, write, position') -----
  readInto: byteArray startingAt: startIndex count: count
  "Read into the given array as specified, and return the count
  actually transferred.  index and count are in units of bytes or
  longs depending on whether the array is Bitmap, String or ByteArray"
 
+ ^(self next: count into: byteArray startingAt: startIndex) size - startIndex + 1
- ^self next: count into: byteArray startingAt: startIndex
  !


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Files-nice.48.mcz

Levente Uzonyi-2
On Mon, 7 Dec 2009, [hidden email] wrote:

> Nicolas Cellier uploaded a new version of Files to project The Trunk:
> http://source.squeak.org/trunk/Files-nice.48.mcz
>
> ==================== Summary ====================
>
> Name: Files-nice.48
> Author: nice
> Time: 7 December 2009, 8:13:37 am
> UUID: d694d4c7-8bb3-9f41-bcaf-805c955c64d8
> Ancestors: Files-ul.47
>
> Restore the semantics of #readInto:startingAt:count: to return the number of bytes read

It seems like I missed that, nice find. :)


Levente

>
> =============== Diff against Files-ul.47 ===============
>
> Item was changed:
>  ----- Method: StandardFileStream>>readInto:startingAt:count: (in category 'read, write, position') -----
>  readInto: byteArray startingAt: startIndex count: count
>   "Read into the given array as specified, and return the count
>   actually transferred.  index and count are in units of bytes or
>   longs depending on whether the array is Bitmap, String or ByteArray"
>
> + ^(self next: count into: byteArray startingAt: startIndex) size - startIndex + 1
> - ^self next: count into: byteArray startingAt: startIndex
>  !
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Files-nice.48.mcz

Nicolas Cellier
2009/12/7 Levente Uzonyi <[hidden email]>:

> On Mon, 7 Dec 2009, [hidden email] wrote:
>
>> Nicolas Cellier uploaded a new version of Files to project The Trunk:
>> http://source.squeak.org/trunk/Files-nice.48.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Files-nice.48
>> Author: nice
>> Time: 7 December 2009, 8:13:37 am
>> UUID: d694d4c7-8bb3-9f41-bcaf-805c955c64d8
>> Ancestors: Files-ul.47
>>
>> Restore the semantics of #readInto:startingAt:count: to return the number
>> of bytes read
>
> It seems like I missed that, nice find. :)
>
>
> Levente
>

Simple, I use this in my benchmarks :)
The test coverage for file streams is so poor... (maybe we'd better
not dig too deep, we might discover weird behaviors)
Anyway, thank you for the good job. You made integration of buffered
read stream quite a simple thing that works
(probably the simplest that could possibly work).

Nicolas

>>
>> =============== Diff against Files-ul.47 ===============
>>
>> Item was changed:
>>  ----- Method: StandardFileStream>>readInto:startingAt:count: (in category
>> 'read, write, position') -----
>>  readInto: byteArray startingAt: startIndex count: count
>>        "Read into the given array as specified, and return the count
>>        actually transferred.  index and count are in units of bytes or
>>        longs depending on whether the array is Bitmap, String or
>> ByteArray"
>>
>> +       ^(self next: count into: byteArray startingAt: startIndex) size -
>> startIndex + 1
>> -       ^self next: count into: byteArray startingAt: startIndex
>>  !
>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Files-nice.48.mcz

Levente Uzonyi-2
On Mon, 7 Dec 2009, Nicolas Cellier wrote:

> Simple, I use this in my benchmarks :)
> The test coverage for file streams is so poor... (maybe we'd better
> not dig too deep, we might discover weird behaviors)

Yes it's almost zero. With green tests I had a few hard to debug errors. I
hope we can replace FileStream and it's subclasses with something better
soon. :)

> Anyway, thank you for the good job. You made integration of buffered
> read stream quite a simple thing that works
> (probably the simplest that could possibly work).

Basically yes, though I reimplemented it from scratch (for fun), but took
several ideas from your implementation. One of the big misteries was that
#next:into:startingAt: didn't work with non-byte based variable classes
(like WordArray and Bitmap). That's because the primitive used by
#replaceFrom:to:with:startingAt: cannot copy from a byte based
variable class to a word based one, but the non-primitive version of the
same method can and it doesn't do it the same way as
#primRead:into:startingAt:count: does.


Levente

>
> Nicolas
>