[squeak-dev] The Inbox: Collections-nice.530.mcz
Nicolas Cellier
nicolas.cellier.aka.nice at gmail.com
Wed Sep 4 10:32:58 UTC 2013
No idea...
Presumably fast up some lookup?
2013/9/4 H. Hirzel <hannes.hirzel at gmail.com>
> What is the aim of the OneCharacterSymbols class?
>
> On Wed, 4 Sep 2013 00:21:42.547 0000, commits at source.squeak.org
> <commits at source.squeak.org> wrote:
> > A new version of Collections was added to project The Inbox:
> > http://source.squeak.org/inbox/Collections-nice.530.mcz
> >
> > ==================== Summary ====================
> >
> > Name: Collections-nice.530
> > Author: nice
> > Time: 4 September 2013, 2:21:28.852 am
> > UUID: d732aa23-1c77-4c1e-abc0-d8d4506b7f9f
> > Ancestors: Collections-ul.529
> >
> > Fix this:
> > self assert: (allSymbols select: [:s | s = '+']) size = 1.
> >
> > 1) It is un-necessary to enumerate the 1-char symbols, they already are
> in
> > SymbolTable (the first time they were created via #findIntern: or by
> virtue
> > of last #rehash) !
> >
> > 2) We can use a WeekArray rather than an Array because there is no point
> in
> > keeping a reference to unused 1-char symbols.
> >
> > Maybe we should get rid of OneCharacterSymbols class var, but I didn't
> > dare...
> >
> > =============== Diff against Collections-ul.529 ===============
> >
> > Item was changed:
> > ----- Method: Symbol class>>allSymbols (in category 'access') -----
> > allSymbols
> > "Answer all interned symbols"
> > ^Array streamContents:[:s|
> > s nextPutAll: NewSymbols.
> > - s nextPutAll: OneCharacterSymbols.
> > s nextPutAll: SymbolTable.
> > ].
> > !
> >
> > Item was changed:
> > ----- Method: Symbol class>>initialize (in category 'class
> > initialization') -----
> > initialize
> >
> > "Symbol initialize"
> >
> > Symbol rehash.
> > + OneCharacterSymbols := WeakArray new: 256.
> > + (0 to: 255) do: [ :byte | byte asCharacter asSymbol].
> > - OneCharacterSymbols := nil.
> > - OneCharacterSymbols := (1 to: 256) collect: [ :i | (i - 1)
> asCharacter
> > asSymbol].
> > Smalltalk addToShutDownList: self.
> > !
> >
> > Item was changed:
> > ----- Method: Symbol class>>internCharacter: (in category 'instance
> > creation') -----
> > internCharacter: aCharacter
> > aCharacter asciiValue > 256 ifTrue:[^self intern: aCharacter
> asString].
> > + ^(OneCharacterSymbols at: aCharacter asciiValue + 1) ifNil:
> > [OneCharacterSymbols at: aCharacter asciiValue + 1 put: (self intern:
> > aCharacter asString)]
> > - OneCharacterSymbols ifNil: [^self intern: aCharacter asString].
> > - ^OneCharacterSymbols at: aCharacter asciiValue + 1
> > !
> >
> > Item was changed:
> > ----- Method: Symbol class>>selectorsContaining: (in category 'access')
> > -----
> > selectorsContaining: aString
> > "Answer a list of selectors that contain aString within them.
> > Case-insensitive. Does return symbols that begin with a capital letter."
> >
> > | size selectorList ascii |
> >
> > selectorList := OrderedCollection new.
> > (size := aString size) = 0 ifTrue: [^selectorList].
> >
> > aString size = 1 ifTrue:
> > [
> > ascii := aString first asciiValue.
> > + ascii < 128 ifTrue: [(OneCharacterSymbols at:
> ascii+1) ifNotNil: [:s |
> > selectorList add: s]]
> > - ascii < 128 ifTrue: [selectorList add:
> (OneCharacterSymbols at:
> > ascii+1)]
> > ].
> >
> > (aString first isLetter or: [aString first isDigit]) ifFalse:
> > [
> > aString size = 2 ifTrue:
> > [Symbol hasInterned: aString ifTrue:
> > [:s | selectorList add: s]].
> > ^selectorList
> > ].
> >
> > selectorList := selectorList copyFrom: 2 to: selectorList size.
> >
> > self allSymbolTablesDo: [:each |
> > each size >= size ifTrue:
> > [(each findSubstring: aString in: each startingAt:
> 1
> > matchTable: CaseInsensitiveOrder) > 0
> > ifTrue: [selectorList add:
> each]]].
> >
> > ^selectorList reject: [:each | "reject non-selectors, but keep
> ones that
> > begin with an uppercase"
> > each numArgs < 0 and: [each asString
> withFirstCharacterDownshifted
> > numArgs < 0]].
> >
> > "Symbol selectorsContaining: 'scon'"!
> >
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20130904/869a6cef/attachment.htm
More information about the Squeak-dev
mailing list
|