#BUGFIX by stefan
authorStefan Vogel <sv@exept.de>
Thu, 31 Aug 2017 14:53:59 +0200
changeset 22229 74cd3c85fcd2
parent 22228 f9b1fd876cbb
child 22230 74a78be266f9
#BUGFIX by stefan class: UninterpretedBytes added: #isSingleByteCollection comment/format in: #isByteCollection changed: #replaceFrom:to:with:startingAt:
UninterpretedBytes.st
--- a/UninterpretedBytes.st	Thu Aug 31 14:51:46 2017 +0200
+++ b/UninterpretedBytes.st	Thu Aug 31 14:53:59 2017 +0200
@@ -4688,11 +4688,11 @@
      Notice: This operation modifies the receiver, NOT a copy;
      therefore the change may affect all others referencing the receiver."
 
-    self class isBytes ifTrue:[
-        ((aCollection class == self class)
-         or:[aCollection isByteCollection]) ifTrue:[
-            ^ self replaceBytesFrom:startIndex to:stopIndex with:aCollection startingAt:repStartIndex
-        ].
+    (self class isBytes 
+     and:[aCollection class == self class or:[aCollection isSingleByteCollection]]
+    ) ifTrue:[
+        "can do it fast: just copy the plain bytes"
+        ^ self replaceBytesFrom:startIndex to:stopIndex with:aCollection startingAt:repStartIndex
     ].
     ^ super replaceFrom:startIndex to:stopIndex with:aCollection startingAt:repStartIndex
 
@@ -5170,6 +5170,7 @@
 
 isByteCollection
     "return true, if the receiver has access methods for bytes;
+     This is different from 'self class isBytes',
      true is returned here - the method is redefined from Object."
 
     ^ true
@@ -5180,6 +5181,16 @@
      false is returned here - the method is redefined from Collection."
 
     ^ false
+!
+
+isSingleByteCollection
+    "return true, if the receiver has access methods for bytes;
+     i.e. #at: and #at:put: accesses a byte and are equivalent to #byteAt: and byteAt:put:
+     and #replaceFrom:to: is equivalent to #replaceBytesFrom:to:. 
+     This is different from 'self class isBytes',
+     true is returned here - the method is redefined from Object."
+
+    ^ true
 ! !
 
 !UninterpretedBytes methodsFor:'visiting'!