[Pharo-project] Issue 3663 in pharo: XMLWriter and MultiByteFileStream

pharo at googlecode.com pharo at googlecode.com
Sun Feb 6 11:54:53 CET 2011


Status: Accepted
Owner: stephane... at gmail.com
Labels: Milestone-1.3

New issue 3663 by stephane... at gmail.com: XMLWriter and MultiByteFileStream
http://code.google.com/p/pharo/issues/detail?id=3663

Name: Collections-ul.422
Author: ul
Time: 31 January 2011, 2:02:00.387 am
UUID: 89c6854c-b6d1-1646-a22b-bbc47ce7522f
Ancestors: Collections-ul.421

Introduced Stream >> #basicNext:putAll:startingAt: which will be used by  
MultiByteFileStream to fix http://bugs.squeak.org/view.php?id=7603 .

=============== Diff against Collections-ul.421 ===============

Item was added:
+ ----- Method: Stream>>basicNext:putAll:startingAt: (in  
category 'accessing') -----
+ basicNext: anInteger putAll: aCollection startingAt: startIndex
+
+       ^self next: anInteger putAll: aCollection startingAt: startIndex
+ !


A fix for http://bugs.squeak.org/view.php?id=7603 . Requires  
Collections-ul.422.

Added TextConverter >> #next:putAll:startingAt:toStream: which is used by  
MultiByteFileStream and MultiByteBinaryOrTextStream to properly implement  
#next:putAll:startingAt:.

=============== Diff against Multilingual-ul.133 ===============

Item was added:
+ ----- Method: MultiByteBinaryOrTextStream>>basicNext:putAll:startingAt:  
(in category 'private basic') -----
+ basicNext: anInteger putAll: aCollection startingAt: startIndex
+
+       ^super next: anInteger putAll: aCollection startingAt: startIndex!

Item was added:
+ ----- Method: MultiByteBinaryOrTextStream>>next:putAll:startingAt: (in  
category 'public') -----
+ next: anInteger putAll: aCollection startingAt: startIndex
+
+       (self isBinary or: [ aCollection class == ByteArray ]) ifTrue: [
+               ^super next: anInteger putAll: aCollection startingAt:  
startIndex ].
+       ^self converter next: anInteger putAll: aCollection startingAt:  
startIndex toStream: self
+ !

Item was added:
+ ----- Method: MultiByteFileStream>>basicNext:putAll:startingAt: (in  
category 'private basic') -----
+ basicNext: anInteger putAll: aCollection startingAt: startIndex
+
+       ^super next: anInteger putAll: aCollection startingAt: startIndex!

Item was added:
+ ----- Method: MultiByteFileStream>>next:putAll:startingAt: (in  
category 'public') -----
+ next: anInteger putAll: aCollection startingAt: startIndex
+
+       (self isBinary or: [ aCollection class == ByteArray ]) ifTrue: [
+               ^super next: anInteger putAll: aCollection startingAt:  
startIndex ].
+       ^converter next: anInteger putAll: aCollection startingAt:  
startIndex toStream: self!

Item was changed:
  ----- Method: MultiByteFileStream>>nextPutAll: (in category 'public') -----
  nextPutAll: aCollection

        (self isBinary or: [aCollection class == ByteArray]) ifTrue: [
                ^ super nextPutAll: aCollection.
        ].
+       ^converter nextPutAll: aCollection toStream: self!
-       converter nextPutAll: aCollection toStream: self.
-       ^aCollection!

Item was added:
+ ----- Method: TextConverter>>next:putAll:startingAt:toStream: (in  
category 'conversion') -----
+ next: anInteger putAll: aString startingAt: startIndex toStream: aStream
+       "Handle fast conversion if ByteString"
+
+       | lastIndex nextIndex |
+       aString class == ByteString ifFalse: [
+               startIndex to: startIndex + anInteger - 1 do: [ :index |
+                       self nextPut: (aString at: index) toStream: aStream  
].
+               ^aString ].
+       aStream isBinary ifTrue: [
+               aStream basicNext: anInteger putAll: aString startingAt:  
startIndex.
+               ^aString ].
+       lastIndex := startIndex.
+       [ (nextIndex := ByteString
+               findFirstInString: aString
+               inSet: latin1Map
+               startingAt: lastIndex) = 0 or: [ nextIndex > anInteger ] ]  
whileFalse: [
+                       aStream
+                               basicNext: nextIndex - lastIndex putAll:  
aString startingAt: lastIndex;
+                               basicNextPutAll: (latin1Encodings at:  
(aString byteAt: nextIndex) + 1).
+                       lastIndex := nextIndex + 1 ].
+       aStream basicNext: anInteger - lastIndex + 1 putAll: aString  
startingAt: lastIndex.
+       ^aString!

Item was changed:
  ----- Method: TextConverter>>nextPutAll:toStream: (in  
category 'conversion') -----
  nextPutAll: aString toStream: aStream
        "Handle fast conversion if ByteString"

+       ^self next: aString size putAll: aString startingAt: 1 toStream:  
aStream!
-       | lastIndex nextIndex |
-       aString class == ByteString ifFalse: [
-               aString do: [:char | self nextPut: char toStream: aStream].
-               ^self].
-
-       aStream isBinary ifTrue: [
-               aStream basicNextPutAll: aString.
-               ^self].
-       lastIndex := 1.
-       [nextIndex := ByteString findFirstInString: aString inSet:  
latin1Map startingAt: lastIndex.
-       nextIndex = 0] whileFalse:
-               [aStream next: nextIndex-lastIndex putAll: aString  
startingAt: lastIndex.
-               aStream basicNextPutAll: (latin1Encodings at: (aString  
byteAt: nextIndex)+1).
-               lastIndex := nextIndex + 1].
-       aStream next: aString size-lastIndex+1 putAll: aString startingAt:  
lastIndex.
-       ^self
- !





More information about the Pharo-project mailing list