[squeak-dev] The Inbox: Collections-ul.869.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Dec 31 14:25:26 UTC 2019


Levente Uzonyi uploaded a new version of Collections to project The Inbox:
http://source.squeak.org/inbox/Collections-ul.869.mcz

==================== Summary ====================

Name: Collections-ul.869
Author: ul
Time: 31 December 2019, 4:46:48.475977 am
UUID: 8b3465a3-235f-4d9d-887c-5ad8ec9bd37c
Ancestors: Collections-nice.868

Various performance tweaks in a single commit:

- be straightforward in Dictionary >> #fillFrom:with:
	- when aCollection is a Dictionary use #associationsDo:, as it very likely it has associations, and it's faster than #keysAndValuesDo:
	- when it's not a Dictionary, use #do: instead of #associationsDo:, because the former is what we can expect a Collection to implement

- use existing search methods in String >> #findDelimiters:startingAt:, because those are faster, and there's no need to reinvent the wheel. All users other than #findTokens:* should be rewritten to use #indexOfAnyOf:* instead.

- almost twice as fast (amortized cost) Symbol >> #lookup: for existing symbols

=============== Diff against Collections-nice.868 ===============

Item was changed:
  ----- Method: Dictionary>>fillFrom:with: (in category 'private') -----
  fillFrom: aCollection with: aBlock
  	"Evaluate aBlock with each of aCollections's elements as the argument.  
  	Collect the resulting values into self. Answer self."
  
  	aCollection isDictionary
+ 		ifFalse: [
+ 			aCollection do: [ :element |
+ 				self add: (aBlock value: element) ] ]
+ 		ifTrue: [
+ 			aCollection associationsDo: [ :association |
+ 				self at: association key put: (aBlock value: association value) ] ]!
- 		ifFalse:
- 			[aCollection associationsDo:
- 				[ :element | self add: (aBlock value: element)]]
- 		ifTrue:
- 			[aCollection keysAndValuesDo:
- 				[ :key :value | self at: key put: (aBlock value: value)]]!

Item was changed:
  ----- Method: String>>findDelimiters:startingAt: (in category 'accessing') -----
  findDelimiters: delimiters startingAt: start 
  	"Answer the index of the character within the receiver, starting at start, that matches one of the delimiters. If the receiver does not contain any of the delimiters, answer size + 1."
  
+ 	delimiters size = 1 ifTrue: [ ^self indexOf: delimiters anyOne startingAt: start ifAbsent: self size + 1 ].
+ 	^self indexOfAnyOf: delimiters startingAt: start ifAbsent: self size + 1!
- 	start to: self size do: [:i |
- 		delimiters do: [:delim | delim = (self at: i) ifTrue: [^ i]]].
- 	^ self size + 1!

Item was changed:
  ----- Method: Symbol class>>lookup: (in category 'instance creation') -----
  lookup: aStringOrSymbol
  
  	| originalNewSymbols originalSymbolTable |
  	originalNewSymbols := NewSymbols.
  	originalSymbolTable := SymbolTable.
+ 	^(originalSymbolTable like: aStringOrSymbol) ifNil: [
+ 		 originalNewSymbols like: aStringOrSymbol ]!
- 	^(originalNewSymbols like: aStringOrSymbol) ifNil: [
- 		originalSymbolTable like: aStringOrSymbol ]!



More information about the Squeak-dev mailing list