## [squeak-dev] The Trunk: Collections-ul.450.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Jul 25 09:22:09 UTC 2011

```Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.450.mcz

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

Name: Collections-ul.450
Author: ul
Time: 25 July 2011, 1:37:20.234 am
UUID: 2d09bd44-bfdf-1840-87cb-81ced69f9948
Ancestors: Collections-nice.449

Avoid a multiplication, use low level methods in
SequenceableCollection >> #polynomialEval: for better performance.

=============== Diff against Collections-nice.449 ===============

Item was changed:
----- Method: SequenceableCollection>>polynomialEval: (in category 'enumerating') -----
polynomialEval: thisX
- 	| sum valToPower |
"Treat myself as the coeficients of a polynomial in X.  Evaluate it with thisX.  First element is the constant and last is the coeficient for the highest power."
"  #(1 2 3) polynomialEval: 2   "   "is 3*X^2 + 2*X + 1 with X = 2"

+ 	| size sum valToPower |
+ 	sum := self at: 1.
+ 	(size := self size) = 1 ifTrue: [ ^sum ].
- 	sum := self first.
valToPower := thisX.
+ 	2 to: size - 1 do: [ :ind |
- 	2 to: self size do: [:ind |
sum := sum + ((self at: ind) * valToPower).
+ 		valToPower := valToPower * thisX ].
+ 	^sum + ((self at: size) * valToPower)!
- 		valToPower := valToPower * thisX].
- 	^ sum!

```