[squeak-dev] The Inbox: Regex-Core-ct.61.mcz

Rolandas Guobys rolandasguobys at gmail.com
Fri Jul 9 16:26:42 UTC 2021

please don't send me more letters !!!

> On 2021-07-09, at 18:10, Levente Uzonyi <leves at caesar.elte.hu> wrote:
> ´╗┐Hi Christoph,
>> On Thu, 8 Jul 2021, christoph.thiede at student.hpi.uni-potsdam.de wrote:
>> Hi Levente,
>> two very fair points, thank you for the feedback! Revisiting #escapeString: again, we do not even need to compile a new regex, which is really expensive, but we can use a simple loop instead:
> I thought you deliberately wanted to use regular expressions there.
>>     | special |
>>     special := self specialCharacters.
>>     ^ String streamContents: [:stream |
>>         aString do: [:char |
>>             (special includes: char) ifTrue: [stream nextPut: $\].
>>             stream nextPut: char]]
>> Which is 90% faster than the original approach. :-)
> If you want the "Best Performance (tm)", there is a Squeak-specific pattern for these kinds of string-rewrite methods, which consists of a precomputed character set and the use of #new:streamContents:, #indexOfAnyOf:startingAt: and #next:putAll:startingAt:.
> String's #format:, #expandMacrosWithArguments:, #unescapePercentsRaw and #jsonWriteOn: (only if you have JSON-ul.56 in your image) all use that pattern.
> Levente
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210709/bfc2659d/attachment.html>

More information about the Squeak-dev mailing list