String.st
branchjv
changeset 17751 b2273fa8d59f
parent 17735 6a5bc05f696a
child 17754 5322906cdb6a
--- a/String.st	Sat Feb 13 18:48:33 2010 +0000
+++ b/String.st	Sat Feb 13 23:34:44 2010 +0000
@@ -669,6 +669,35 @@
     ].
     super basicAt:index put:aCharacter codePoint.
     ^ aCharacter
+!
+
+first
+    "return the first character.
+     Reimplemented here for speed"
+
+%{  /* NOCONTEXT */
+
+    REGISTER int indx;
+    REGISTER OBJ slf, cls;
+
+    slf = self;
+    cls = __qClass(slf);
+    indx = 0;
+    if (cls != String) {
+        if (indx < 0) goto badIndex;
+        indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+    }
+    if ((unsigned)indx < (unsigned)(__stringSize(slf))) {
+        RETURN ( __MKCHARACTER(__stringVal(slf)[indx] & 0xFF) );
+    }
+badIndex: ;
+%}.
+    ^ super first
+
+    "
+     'abc' first
+     '' first
+    "
 ! !
 
 
@@ -1936,6 +1965,18 @@
     "Modified: / 02-08-2007 / 16:43:29 / cg"
 !
 
+uncapitalized
+        "Answer a <readableString> which is a copy of the receiver but with
+        the first character converted to its lowercase equivalent."
+
+        ^ self asLowercaseFirst
+"/        | answer |
+"/        #swAdded.
+"/        (answer := self copy) isEmpty ifFalse: [
+"/                answer at: 1 put: (self first asLowercase)].
+"/        ^answer
+!
+
 withTabsExpanded:numSpaces
     "return a string with the characters of the receiver where all tabulator characters
      are expanded into spaces (assuming numSpaces-col tabs).
@@ -3681,12 +3722,13 @@
 !String class methodsFor:'documentation'!
 
 version
-    ^ '$Id: String.st 10480 2009-12-02 21:30:55Z vranyj1 $'
+    ^ '$Id: String.st 10501 2010-02-13 23:34:44Z vranyj1 $'
 !
 
 version_CVS
-    ^ '§Header: /cvs/stx/stx/libbasic/String.st,v 1.268 2009/11/05 16:26:29 stefan Exp §'
+    ^ '§Header: /cvs/stx/stx/libbasic/String.st,v 1.270 2010/02/10 17:47:03 cg Exp §'
 ! !
 
 
 
+