[squeak-dev] The Trunk: ToolBuilder-Morphic-fbs.88.mcz

Frank Shearar frank.shearar at gmail.com
Sat Mar 2 07:57:04 UTC 2013


On 2 March 2013 00:28, Levente Uzonyi <leves at elte.hu> wrote:
> This will be inefficient if there are many prefixMatches and patternMatches,
> because #difference will take O(n*m) time. I started measuring it and the
> highest number I got was 100ms, which is acceptable, but on a slower machine
> without Cog it can be a few seconds, which is rather slow.
>
> I have an optimized version, but it's not clear what the goal of this code
> is:
>
>
>> +                               pattern := (searchText beginsWith: '*')
>> +                                       ifTrue: [searchText]
>> +                                       ifFalse: ['*', searchText, '*'].
>
>
> If searchText is "*MC", then pattern will be "*MC", but if the searchText is
> "MC*", then it will be "*MC*". I think using #includes: instead of
> #beginsWith: matches with what the intention was. Anyway, I'll just push my
> version to the Inbox.

Yes: I'd intended "no wild cards" to mean "match on substring", with
the assumption that the use of a wildcard implies the user knows what
she wants.

I'd be happy to see the code optimised; I thought about trying to do
the thing in one traversal but the code looked really ugly. Do it
right, then make it fast.

Glad to see some mails from you, Levente!

frank


More information about the Squeak-dev mailing list