[ENH] String repeat
David N. Smith (IBM)
dnsmith at watson.ibm.com
Mon May 29 00:52:36 UTC 2000
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
-------------- next part --------------
Skipped content of type multipart/appledouble-------------- next part --------------
Skipped content of type multipart/appledouble-------------- next part --------------
_______________________________
David N. Smith
IBM T J Watson Research Center
Hawthorne, NY
_______________________________
Any opinions or recommendations
herein are those of the author
and not of his employer.
More information about the Squeak-dev
mailing list
|