Improved SystemUtils class>>validateName:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Improved SystemUtils class>>validateName:

Andres Valloud-2
Hello,

I have a bundle with about 270 classes in it, and I couldn't help
noticing that publishing the bundle was taking one minute.  I inserted
a TimeProfiler profile: in an appropriate place and republished a mock
set of changes.  It turns out that many strings are being created, or
their contents are being replaced, etc.  And at the leaves of the time
profiler, SystemUtils class>>validateName: appeared quite frequently.

Upon inspection, it seems like this improved implementation can do the
same thing while creating significantly less garbage.  As such, it cut
about 20% of time needed to publish the package (but I only did one
run so far).

SystemUtils class >> validateName: varName

        | parser allCharactersAreAcceptable |
        varName isEmpty ifTrue: [^nil].
        parser := Compiler preferredParserClass new.
        allCharactersAreAcceptable := varName
                allSatisfy: [:char | (parser isLetter: char) or: [char isDigit]].
        allCharactersAreAcceptable ifFalse: [^nil].
        ^varName asSymbol


Hopefully somebody will find this useful.  I did this in my 7.2.1
image, so maybe this has already been improved in 7.4x.
       
--
Best regards,
 Andres                          mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Improved SystemUtils class>>validateName:

Bob Westergaard-2


On Sun, 7 May 2006, Andres Valloud wrote:

> Hello,
>
> I have a bundle with about 270 classes in it, and I couldn't help

I've gathered up the changesets from the six emails you sent dealing with
potential store speeds and will see what we can use for 7.5.  I've created
AR 50769 to cover these changes.

Thanks!
-- Bob