On 07/04/2011 01:14 PM, Paolo Bonzini wrote:
On 07/04/2011 12:05 PM, Gwenael Casaccio wrote:
So here is the patch.
This is not a patch, it is 10 patches including multiple reverts of
pieces that you have already submitted.
You should have grouped the patches in two, one for #beConsistent and
one squashing everything else.
I've changed OrederedCollection to use
#replaceFrom:to:with:startingAt, SortedCollection uses the Smalltalk
implementation but for growing I call the primitive. And OrderedSet uses
the St implementation.
Why? Is it just because the ordered_set_class is not available? I
believe this rather shows that class checks are too specific.
I pulled some changes in stable-3.2 and others in master only. Please
test master and see how performance compares with your code.
Paolo
Hi,
here is a new patch:
- #replaceFrom: cannot be called in SortedCollection
- add basicFirstIndex which return the position of the first object
make check is green
Gwen
diff --git a/kernel/Array.st b/kernel/Array.st
index b3ef3fd..009c803 100644
--- a/kernel/Array.st
+++ b/kernel/Array.st
@@ -76,7 +76,7 @@ and general access behavior from SequenceableCollection.'>
^self isReadOnly not
]
- replaceFrom: start to: stop with: byteArray startingAt: replaceStart [
+ replaceFrom: start to: stop with: aCollection startingAt: replaceStart [
"Replace the characters from start to stop with new characters whose
ASCII codes are contained in byteArray, starting at the replaceStart
location of byteArray"
@@ -86,7 +86,7 @@ and general access behavior from SequenceableCollection.'>
^super
replaceFrom: start
to: stop
- with: byteArray
+ with: aCollection
startingAt: replaceStart
]
diff --git a/kernel/Collection.st b/kernel/Collection.st
index 948b62f..de93e1d 100644
--- a/kernel/Collection.st
+++ b/kernel/Collection.st
@@ -647,4 +647,10 @@ of objects.'>
self remove: anObject ifAbsent: [].
self == Object finalizableObjects ifTrue: [anObject key finalize]
]
+
+ basicFirstIndex [
+ <category: 'accessing'>
+
+ ^ 1
+ ]
]
diff --git a/kernel/OrderColl.st b/kernel/OrderColl.st
index 9f0cf29..daecc16 100644
--- a/kernel/OrderColl.st
+++ b/kernel/OrderColl.st
@@ -508,15 +508,49 @@ on content (such as add:after:)'>
self become: newOrderedCollection
]
- primReplaceFrom: start to: stop with: byteArray startingAt: replaceStart [
- "Replace the characters from start to stop with new characters whose
- ASCII codes are contained in byteArray, starting at the replaceStart
- location of byteArray"
+ basicFirstIndex [
+ <category: 'accessing'>
+
+ ^ firstIndex
+ ]
+
+ replaceFrom: start to: stop with: aCollection startingAt: replaceStart [
+ "Replace the objects from start to stop with new objects whose
+ items are contained in aCollection, starting at the replaceStart
+ location of aCollection"
+
+ <category: 'built ins'>
+
+ | minStop maxStop size |
+ size := aCollection size.
+ minStop := start - 1.
+ maxStop := self size min: minStop + size.
+ (start <= stop and: [ start >= 1 and: [ stop <= maxStop ] ])
+ ifFalse: [
+ ^ SystemExceptions.ArgumentOutOfRange
+ signalOn: stop
+ mustBeBetween: minStop
+ and: maxStop ].
+ (replaceStart + stop - start) > size ifTrue: [
+ ^ SystemExceptions.ArgumentOutOfRange
+ signalOn: replaceStart
+ mustBeBetween: 1
+ and: size ].
+ ^ self
+ primReplaceFrom: firstIndex + start - 1
+ to: firstIndex + stop - 1
+ with: aCollection
+ startingAt: aCollection basicFirstIndex + replaceStart - 1
+ ]
+
+ primReplaceFrom: start to: stop with: aCollection startingAt: replaceStart [
+ "Replace the objects from start to stop with new objects whose
+ items are contained in aCollection, starting at the replaceStart
+ location of aCollection"
<category: 'built ins'>
<primitive: VMpr_ArrayedCollection_replaceFromToWithStartingAt>
- self primitiveFailed
+ self primitiveFailed
]
-
]
diff --git a/kernel/SortCollect.st b/kernel/SortCollect.st
index ef8a8bc..0e97f24 100644
--- a/kernel/SortCollect.st
+++ b/kernel/SortCollect.st
@@ -113,6 +113,11 @@ above criteria -- actually any object which responds to #value:value:.'>
self shouldNotImplement
]
+ replaceFrom: start to: stop with: aCollection startingAt: replaceStart [
+ <category: 'disabled'>
+ self shouldNotImplement
+ ]
+
do: aBlock [
"Evaluate aBlock for all the elements in the collection"
_______________________________________________
help-smalltalk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-smalltalk