[squeak-dev] The Trunk: Collections-nice.936.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Apr 13 20:22:26 UTC 2021
Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.936.mcz
==================== Summary ====================
Name: Collections-nice.936
Author: nice
Time: 13 April 2021, 10:21:49.89342 pm
UUID: 8d324920-b4ed-f84c-86e7-a4dcd3e7a1c9
Ancestors: Collections-mt.935
Move findInterned: to deprecated
Comment a few essential class side selectors.
=============== Diff against Collections-mt.935 ===============
Item was changed:
+ ----- Method: Symbol class>>allSymbols (in category 'accessing') -----
- ----- Method: Symbol class>>allSymbols (in category 'access') -----
allSymbols
"Answer all interned symbols"
| originalNewSymbols originalSymbolTable |
originalNewSymbols := NewSymbols.
originalSymbolTable := SymbolTable.
^Array
new: originalNewSymbols slowSize + originalSymbolTable slowSize
streamContents:[ :stream |
stream
nextPutAll: originalNewSymbols;
nextPutAll: originalSymbolTable ]
!
Item was removed:
- ----- Method: Symbol class>>findInterned: (in category 'instance creation') -----
- findInterned:aString
-
- self hasInterned:aString ifTrue:[:symbol| ^symbol].
- ^nil.!
Item was changed:
----- Method: Symbol class>>intern: (in category 'instance creation') -----
intern: aStringOrSymbol
+ "Answer the unique Symbol formed with given String.
+ If it does not exist yet, create it and intern it in the NewSymbols.
+ Interning a Symbol should return the Symbol itself, no Symbol should be duplicated"
| originalNewSymbols |
originalNewSymbols := NewSymbols.
^(self lookup: aStringOrSymbol) ifNil:[
| aSymbol newNewSymbols |
aStringOrSymbol isSymbol ifTrue:[
aSymbol := aStringOrSymbol.
] ifFalse:[
aSymbol := (aStringOrSymbol isOctetString ifTrue:[ByteSymbol] ifFalse:[WideSymbol])
new: aStringOrSymbol size.
aSymbol string: aStringOrSymbol.
aSymbol beReadOnlyObject.
].
newNewSymbols := originalNewSymbols copyWith: aSymbol.
originalNewSymbols == NewSymbols
ifTrue: [
NewSymbols := newNewSymbols.
newNewSymbols size > 1000 ifTrue: [ self condenseNewSymbols ].
aSymbol ]
ifFalse: [
"Some other process has modified the symbols. Try again."
self intern: aStringOrSymbol ] ]!
Item was changed:
----- Method: Symbol class>>lookup: (in category 'instance creation') -----
lookup: aStringOrSymbol
+ "Answer the unique Symbol formed with given String, if it exists.
+ Answer nil if no such Symbol does exist yet.
+ Looking up a Symbol should return the Symbol itself
+ - no Symbol should be duplicated
+ - every Symbol should be registered in one of the two Symbol tables"
| originalNewSymbols originalSymbolTable |
originalNewSymbols := NewSymbols.
originalSymbolTable := SymbolTable.
^(originalSymbolTable like: aStringOrSymbol) ifNil: [
originalNewSymbols like: aStringOrSymbol ]!
Item was changed:
+ ----- Method: Symbol class>>selectorsContaining: (in category 'accessing') -----
- ----- 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 |
selectorList := OrderedCollection new.
(size := aString size) = 0 ifTrue: [ ^selectorList ].
self allSymbolTablesDo: [ :each |
(each size >= size
and: [ (each includesSubstring: aString caseSensitive: false)
and: [ each numArgs ~= -1 ] ])
ifTrue: [ selectorList add: each ] ].
^selectorList
"Symbol selectorsContaining: 'scon'"!
Item was changed:
+ ----- Method: Symbol class>>selectorsMatching: (in category 'accessing') -----
- ----- Method: Symbol class>>selectorsMatching: (in category 'access') -----
selectorsMatching: aStringPattern
"Answer a list of selectors that match aStringPattern within them. Case-insensitive. Does return symbols that begin with a capital letter."
| selectorList |
selectorList := OrderedCollection new.
aStringPattern isEmpty ifTrue: [ ^selectorList ].
self allSymbolTablesDo: [ :each |
((aStringPattern match: each) and: [ each numArgs ~= -1 ])
ifTrue: [selectorList add: each ] ].
^selectorList
"Symbol selectorsMatching: 'parse:*'"!
Item was changed:
+ ----- Method: Symbol class>>thatStarts:skipping: (in category 'accessing') -----
- ----- Method: Symbol class>>thatStarts:skipping: (in category 'access') -----
thatStarts: leadingCharacters skipping: skipSym
"Answer a selector symbol that starts with leadingCharacters.
Symbols beginning with a lower-case letter handled directly here.
Ignore case after first char.
If skipSym is not nil, it is a previous answer; start searching after it.
If no symbols are found, answer nil.
Used by Alt-q (Command-q) routines"
| size firstMatch key |
size := leadingCharacters size.
size = 0 ifTrue: [^skipSym ifNil: [#''] ifNotNil: [nil]].
firstMatch := leadingCharacters at: 1.
size > 1 ifTrue: [key := leadingCharacters copyFrom: 2 to: size].
self allSymbolTablesDo: [:each |
each size >= size ifTrue:
[
((each at: 1) == firstMatch and:
[key == nil or:
[(each findString: key startingAt: 2 caseSensitive: false) = 2]])
ifTrue: [^each]
]
] after: skipSym.
^nil
"Symbol thatStarts: 'sf' skipping: nil"
"Symbol thatStarts: 'sf' skipping: #sfpGetFile:with:with:with:with:with:with:with:with:"
"Symbol thatStarts: 'candidate' skipping: nil"
!
Item was changed:
+ ----- Method: Symbol class>>thatStartsCaseSensitive:skipping: (in category 'accessing') -----
- ----- Method: Symbol class>>thatStartsCaseSensitive:skipping: (in category 'access') -----
thatStartsCaseSensitive: leadingCharacters skipping: skipSym
"Same as thatStarts:skipping: but caseSensitive"
| size firstMatch key |
size := leadingCharacters size.
size = 0 ifTrue: [^skipSym ifNil: [#''] ifNotNil: [nil]].
firstMatch := leadingCharacters at: 1.
size > 1 ifTrue: [key := leadingCharacters copyFrom: 2 to: size].
self allSymbolTablesDo: [:each |
each size >= size ifTrue:
[
((each at: 1) == firstMatch and:
[key == nil or:
[(each findString: key startingAt: 2 caseSensitive: true) = 2]])
ifTrue: [^each]
]
] after: skipSym.
^nil
!
More information about the Squeak-dev
mailing list
|