[squeak-dev] The Trunk: Collections-ar.121.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Aug 28 03:43:35 UTC 2009


Andreas Raab uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ar.121.mcz

==================== Summary ====================

Name: Collections-ar.121
Author: ar
Time: 27 August 2009, 8:43:09 am
UUID: b5271f0f-8838-9449-bddb-986e082835e7
Ancestors: Collections-ar.120

Adds String>>asPrecomposedUnicode and String>>asDecomposedUnicode for quick conversions between precomposed and decomposed Unicode string representations.

=============== Diff against Collections-ar.120 ===============

Item was added:
+ ----- Method: String>>asPrecomposedUnicode (in category 'converting') -----
+ asPrecomposedUnicode
+ 	"Convert the receiver into a precomposed Unicode representation.
+ 	Optimized for the common case that no composition needs to take place."
+ 	| lastIndex nextIndex composed out |
+ 	lastIndex := 1.
+ 	nextIndex := 0.
+ 	[(nextIndex := nextIndex+1) < self size] whileTrue:[
+ 		composed := Unicode compose: (self at: nextIndex) with: (self at: nextIndex+1).
+ 		composed ifNotNil:[
+ 			lastIndex = 1 ifTrue:[out := WriteStream on: (String new: self size)].
+ 			out nextPutAll: (self copyFrom: lastIndex to: nextIndex-1).
+ 			out nextPut: composed.
+ 			nextIndex := nextIndex+1.
+ 			lastIndex := nextIndex+1.
+ 		].
+ 	].
+ 	^out ifNil:[self] ifNotNil:[
+ 		out nextPutAll: (self copyFrom: lastIndex to: self size).
+ 		out contents]!

Item was added:
+ ----- Method: String>>asDecomposedUnicode (in category 'converting') -----
+ asDecomposedUnicode
+ 	"Convert the receiver into a decomposed Unicode representation.
+ 	Optimized for the common case that no decomposition needs to take place."
+ 	| lastIndex nextIndex out decomposed |
+ 	lastIndex := 1.
+ 	nextIndex := 0.
+ 	[(nextIndex := nextIndex+1) <= self size] whileTrue:[
+ 		decomposed := Unicode decompose: (self at: nextIndex).
+ 		decomposed ifNotNil:[
+ 			lastIndex = 1 ifTrue:[out := WriteStream on: (String new: self size)].
+ 			out nextPutAll: (self copyFrom: lastIndex to: nextIndex-1).
+ 			out nextPutAll: decomposed.
+ 			lastIndex := nextIndex+1.
+ 		].
+ 	].
+ 	^out ifNil:[self] ifNotNil:[
+ 		out nextPutAll: (self copyFrom: lastIndex to: self size).
+ 		out contents]!




More information about the Squeak-dev mailing list