String.st
changeset 11906 b6decf7e7d52
parent 11883 36c27310fd24
child 11921 e2c2786daab1
--- a/String.st	Tue Sep 08 19:06:47 2009 +0200
+++ b/String.st	Tue Sep 08 19:06:58 2009 +0200
@@ -1733,21 +1733,26 @@
 !String methodsFor:'converting'!
 
 asArrayOfSubstrings
-	"Answer an array with all the substrings of the receiver separated by
-	separator characters (space, cr, tab, linefeed, formfeed, etc)."
-
-	| substrings start end |
-	substrings _ OrderedCollection new.
-	start _ 1.
-	[start <= self size] whileTrue: [
-		(self at: start) isSeparator ifFalse: [
-			end _ start + 1.
-			[end <= self size and: [(self at: end) isSeparator not]]
-				whileTrue: [end _ end + 1].
-			substrings add: (self copyFrom: start to: end - 1).
-			start _ end - 1].
-		start _ start + 1].
-	^ substrings asArray
+    "Answer an array with all the substrings of the receiver separated by
+     separator characters (space, cr, tab, linefeed, formfeed, etc).
+     CG: This is ported Squeak code, and I am not sure if it is more efficient than
+         the inherited one... after all: who added it anyway ?"
+
+    | substrings start end |
+
+    substrings := OrderedCollection new.
+    start := 1.
+    [start <= self size] whileTrue: [
+        (self at: start) isSeparator ifFalse: [
+            end := start + 1.
+            [end <= self size and: [(self at: end) isSeparator not]]
+                whileTrue: [end := end + 1].
+            substrings add: (self copyFrom: start to: end - 1).
+            start := end - 1
+        ].
+        start := start + 1
+    ].
+    ^ substrings asArray
 !
 
 asAsciiZ
@@ -3182,6 +3187,7 @@
     ^ super reverse
 ! !
 
+
 !String methodsFor:'substring searching'!
 
 indexOfSubCollection:aSubString startingAt:startIndex ifAbsent:exceptionValue caseSensitive:caseSensitive
@@ -3646,5 +3652,5 @@
 !String class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.261 2009-08-28 09:33:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.262 2009-09-08 17:06:58 cg Exp $'
 ! !