Skip to content

Commit f7faade

Browse files
committed
Speed up new #sum method
1 parent 98dd08b commit f7faade

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/DataFrame/DataSeries.class.st

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,10 @@ DataSeries >> sortedDescending [
664664
DataSeries >> sum [
665665
"Return the sum of the values over the requested axis. Nil values are excluded."
666666

667-
^ (self reject: #isNil) inject: 0 into: [ :accum :each | accum + each ]
667+
| result |
668+
result := 0.
669+
self do: [ :each | each ifNotNil: [ result := result + each ] ].
670+
^ result
668671
]
669672

670673
{ #category : #statistics }

0 commit comments

Comments
 (0)