[ENH] String repeat

Brent Pinkney Brent at astarte.co.nz
Mon May 29 01:07:34 UTC 2000


Should it be #repeat: for readability ? 

Followng the principle of least suprise, shouldnt a new programmer expect it
to be similar to #timesRepeat: 

Nevermind the readability.

<banter>
	Or have we adopted unix\c conventions ? Ala creat() instead of
create()
</banter>

-----Original Message-----
From: David N. Smith (IBM) [mailto:dnsmith at watson.ibm.com]
Sent: Monday, 29 May 2000 12:53
To: squeak at cs.uiuc.edu
Subject: [ENH] String repeat


Attached is a method I've evolved over a while which does string repeats:

	'0' rep: 5    ==>    '00000'

It runs very fast for large repeats, approaching the rate at which the VM
can move data in large hunks. It works by allocating a buffer the size of
the result, then copying in self. At each step the string is copied to the
just past the highest used position in the result, thus doubling the results
size at each step. One final copy to fill in the end of the result may be
needed. An existing primitive is used for the copying.

Dave





More information about the Squeak-dev mailing list