[Pharo-users] Slow object printOn: with EURO symbol

Henrik Johansen henrik.s.johansen at veloxit.no
Mon Jan 4 05:05:14 EST 2016

> On 02 Jan 2016, at 10:58 , Hilaire <hilaire at drgeo.eu> wrote:
> Hello,
> With Pharo3, in an object of mine, I want its text representation to
> come with the EURO symbol:
> CGMoney>>printOn: aStream
> 	aStream << (amount asScaledDecimal: 2) greaseString
> 		<< ' ' << '€'
> It appears to be very slow when I browse such collection of objects
> (says 1500) from an inspector
> Replacing '€' by 'EUR' gives back normal rendering time.
> Indeed the '€' is encoded as WideString, so not sure what is happening.
> All content converted to WideString or what?

In the fallback code for WriteStream >> #nextPut:, at:put: is called,  so yes, streaming a wide char causes the streams collection to be converted from Byte to WideString.
Conversion is done using become, which currently triggers a full heap scan for references, and is thus very slow.
One could add a fast-path along the lines of #pastEndPut: (which has already broken any assumption that a reference to the collection will reflect all writes for the lifetime of stream, for the same performance problems one would face using #become:); if collection is a ByteString and anObject is a wide characters, replace collection with a WideString, and *then* call at:put:
But, it is not a very nice thing to add to a generic streaming class, nor is it a very attractive at this point in time considering that making become: a fast operation is one of the problems solved by Spur.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20160104/ac67bb8e/attachment.asc>

More information about the Pharo-users mailing list