Skip to content

Commit 75a7788

Browse files
committed
Speed up creation of data series
I set the size of the dataseries so that we do not need to grow the collection as we add elements (it can double the speed on creation)
1 parent cb5244e commit 75a7788

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/DataFrame/DataSeries.class.st

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ DataSeries class >> newFrom: aCollection [
2121
ifFalse: [ aCollection withIndexCollect: [ :each :i | i -> each ] ])
2222
]
2323

24+
{ #category : #'instance creation' }
25+
DataSeries class >> newFromKeys: keys andValues: values [
26+
27+
| dict |
28+
self flag: #pharo12. "This is a copy of the superclass with a speed up. I'll propose this speedup in Pharo 12 so when Pharo 12 will be the minimal suuported version then we can drop this method."
29+
dict := self new: keys size.
30+
keys with: values do: [ :k :v | dict at: k put: v ].
31+
^ dict
32+
]
33+
2434
{ #category : #'instance creation' }
2535
DataSeries class >> withKeys: keys values: values [
2636
^ self newFromKeys: keys andValues: values

0 commit comments

Comments
 (0)