Eliot Miranda uploaded a new version of Environments to project The Trunk: http://source.squeak.org/trunk/Environments-eem.85.mcz
==================== Summary ====================
Name: Environments-eem.85 Author: eem Time: 4 May 2023, 12:18:59.95869 pm UUID: 162eabaa-b8ca-479f-8062-8e2c4fc3aea9 Ancestors: Environments-ul.84
Neater, faster classOrTraitNamed:, which almost always is given a class name, not a metaclass or trait class name.
=============== Diff against Environments-ul.84 ===============
Item was changed: ----- Method: Environment>>classOrTraitNamed: (in category 'classes and traits') ----- classOrTraitNamed: aString "aString is either a class or trait name or a class or trait name followed by ' class' or 'classTrait' respectively. + Answer the class or metaclass it names, or nil if not found." - Answer the class or metaclass it names."
+ | spaceIndex postFix meta baseName | + spaceIndex := aString indexOf: Character space. + spaceIndex = 0 + ifTrue: + [meta := false. + baseName := aString] + ifFalse: + [postFix := aString copyFrom: spaceIndex + 1 to: aString size. + baseName := aString copyFrom: 1 to: spaceIndex - 1. + (postFix = 'class' or: [postFix = 'classTrait']) + ifTrue: [meta := true] + ifFalse: [^nil]]. + ^(Symbol lookup: baseName) ifNotNil: + [ :baseNameSymbol | + declarations + at: baseNameSymbol + ifPresent: + [ :global | + global isBehavior ifTrue: + [meta + ifFalse: [ global ] + ifTrue: [ global classSide ] ] ] ]! - | meta baseName | - (aString endsWith: ' class') - ifTrue: [ - meta := true. - baseName := aString copyFrom: 1 to: aString size - 6 ] - ifFalse: [ - (aString endsWith: ' classTrait') - ifTrue: [ - meta := true. - baseName := aString copyFrom: 1 to: aString size - 11 ] - ifFalse: [ - meta := false. - baseName := aString ] ]. - ^(Symbol lookup: baseName) ifNotNil: [ :baseNameSymbol | - declarations at: baseNameSymbol ifPresent: [ :global | - global isBehavior ifTrue: [ - meta - ifFalse: [ global ] - ifTrue: [ global classSide ] ] ] ]!
squeak-dev@lists.squeakfoundation.org