[squeak-dev] The Trunk: Collections-tfel.623.mcz

Eliot Miranda eliot.miranda at gmail.com
Sun May 3 20:44:29 UTC 2015


Hi Levente,

On May 3, 2015, at 5:12 AM, Levente Uzonyi <leves at elte.hu> wrote:

> On Fri, 1 May 2015, commits at source.squeak.org wrote:
> 
>> Tim Felgentreff uploaded a new version of Collections to project The Trunk:
>> http://source.squeak.org/trunk/Collections-tfel.623.mcz
>> 
>> ==================== Summary ====================
>> 
>> Name: Collections-tfel.623
>> Author: tfel
>> Time: 1 May 2015, 11:06:35.625 am
>> UUID: baf2902d-52b9-2442-a513-8a5a6ff0ce30
>> Ancestors: Collections-nice.622
>> 
>> fix fallback code for ByteString>>findSubstring:in:startingAt:matchTable: when passing a starting index <= 0
> 
> If I'm not mistaken, this is the slang code that gets compiled to C. Does slang support #max:?

Yes

> 
> Levente
> 
>> 
>> =============== Diff against Collections-nice.622 ===============
>> 
>> Item was changed:
>> ----- Method: ByteString>>findSubstring:in:startingAt:matchTable: (in category 'comparing') -----
>> findSubstring: key in: body startingAt: start matchTable: matchTable
>>    "Answer the index in the string body at which the substring key first occurs, at or beyond start.  The match is determined using matchTable, which can be used to effect, eg, case-insensitive matches.  If no match is found, zero will be returned.
>> 
>>    The algorithm below is not optimum -- it is intended to be translated to C which will go so fast that it wont matter."
>>    | index |
>>    <primitive: 'primitiveFindSubstring' module: 'MiscPrimitivePlugin'>
>>    <var: #key declareC: 'unsigned char *key'>
>>    <var: #body declareC: 'unsigned char *body'>
>>    <var: #matchTable declareC: 'unsigned char *matchTable'>
>> 
>>    key size = 0 ifTrue: [^ 0].
>> +    (start max: 1) to: body size - key size + 1 do:
>> -    start to: body size - key size + 1 do:
>>        [:startIndex |
>>        index := 1.
>>            [(matchTable at: (body at: startIndex+index-1) asciiValue + 1)
>>                = (matchTable at: (key at: index) asciiValue + 1)]
>>                whileTrue:
>>                [index = key size ifTrue: [^ startIndex].
>>                index := index+1]].
>>    ^ 0
>> "
>> ' ' findSubstring: 'abc' in: 'abcdefabcd' startingAt: 1 matchTable: CaseSensitiveOrder 1
>> ' ' findSubstring: 'abc' in: 'abcdefabcd' startingAt: 2 matchTable: CaseSensitiveOrder 7
>> ' ' findSubstring: 'abc' in: 'abcdefabcd' startingAt: 8 matchTable: CaseSensitiveOrder 0
>> ' ' findSubstring: 'abc' in: 'abcdefABcd' startingAt: 2 matchTable: CaseSensitiveOrder 0
>> ' ' findSubstring: 'abc' in: 'abcdefABcd' startingAt: 2 matchTable: CaseInsensitiveOrder 7
>> "!
> 


More information about the Squeak-dev mailing list