--- a/String.st Sat Mar 23 21:45:49 2019 +0100
+++ b/String.st Sun Mar 24 10:08:29 2019 +0100
@@ -187,117 +187,98 @@
REGISTER unsigned char *cp;
int nInstVars;
+ // fetch first; check later
+ // (if not a smallInteger, value will be ignored anyway)
+ len = __intVal(anInteger);
+ instsize = OHDR_SIZE + len + 1;
if (__isSmallInteger(anInteger)) {
- len = __intVal(anInteger);
- if (len >= 0) {
- instsize = OHDR_SIZE + len + 1;
- if (self == String || self == ImmutableString) {
- if (__CanDoQuickNew(instsize)) { /* OBJECT ALLOCATION */
- /*
- * the most common case
- */
- __qCheckedNew(newString, instsize);
- __InstPtr(newString)->o_class = self; /* no need for PROTECT - there was no GC */
- __qSTORE(newString, self);
-
- cp = __stringVal(newString);
-
+ if (len >= 0) {
+ if (self == String || self == ImmutableString) {
+ if (__CanDoQuickNew(instsize)) { /* OBJECT ALLOCATION */
+ /*
+ * the most common case
+ */
+ __qCheckedNew(newString, instsize);
+ __InstPtr(newString)->o_class = self; /* no need for PROTECT - there was no GC */
+ __qSTORE(newString, self);
+
+ cp = __stringVal(newString);
+ fillIt:
+ // fill bytes at cp
# if defined(memset4)
- {
- /*
- * no sizeof(int) here please -
- * - memset4 (if defined) fills 4-bytes on ALL machines
- */
- int l4 = len >> 2;
-
- if (len & 3) l4++;
- memset4(cp, 0x20202020, l4);
- cp[len] = '\0';
- }
+ {
+ /*
+ * no sizeof(int) here please -
+ * - memset4 (if defined) fills 4-bytes on ALL machines
+ */
+ int l4 = len >> 2;
+
+ if (len & 3) l4++;
+ memset4(cp, 0x20202020, l4);
+ cp[len] = '\0';
+ }
# else
# ifdef FAST_MEMSET
- memset(cp, ' ', len);
- cp[len] = '\0';
+ memset(cp, ' ', len);
+ cp[len] = '\0';
# else
- for ( ; len >= 8; cp += 8, len -= 8) {
+ for ( ; len >= 8; cp += 8, len -= 8) {
# ifdef INT64
- ((INT64 *)cp)[0] = 0x2020202020202020L;
+ ((INT64 *)cp)[0] = 0x2020202020202020L;
# else
- ((int *)cp)[0] = 0x20202020;
- ((int *)cp)[1] = 0x20202020;
+ ((int *)cp)[0] = 0x20202020;
+ ((int *)cp)[1] = 0x20202020;
# endif
- }
- while (len--)
- *cp++ = ' ';
- *cp = '\0';
+ }
+ while (len--)
+ *cp++ = ' ';
+ *cp = '\0';
# endif /* not FAST_MEMSET */
# endif /* not memset4 */
- RETURN (newString);
- }
- nInstVars = 0;
- } else {
- nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars);
- instsize += __OBJS2BYTES__(nInstVars);
- }
-
- __PROTECT_CONTEXT__;
- __qNew(newString, instsize); /* OBJECT ALLOCATION */
- __UNPROTECT_CONTEXT__;
-
- if (newString == nil) goto fail;
-
- __InstPtr(newString)->o_class = self;
- __qSTORE(newString, self);
-
- cp = __stringVal(newString);
- if (nInstVars) {
- OBJ *op;
- cp += __OBJS2BYTES__(nInstVars);
-
- /*
- * nil-out instvars
- */
+ RETURN (newString);
+ }
+ nInstVars = 0;
+ } else {
+ nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars);
+ instsize += __OBJS2BYTES__(nInstVars);
+ }
+
+ __PROTECT_CONTEXT__;
+ __qNew(newString, instsize); /* OBJECT ALLOCATION */
+ __UNPROTECT_CONTEXT__;
+
+ if (newString == nil) goto fail;
+
+ __InstPtr(newString)->o_class = self;
+ __qSTORE(newString, self);
+
+ cp = __stringVal(newString);
+ if (nInstVars) {
+ OBJ *op;
+ cp += __OBJS2BYTES__(nInstVars);
+
+ /*
+ * nil-out instvars
+ */
# if defined(memset4)
- memset4(__InstPtr(newString)->i_instvars, nil, nInstVars);
+ memset4(__InstPtr(newString)->i_instvars, nil, nInstVars);
# else
# if defined(FAST_MEMSET) && ! defined(NEGATIVE_ADDRESSES)
- /*
- * knowing that nil is 0
- */
- memset(__InstPtr(newString)->i_instvars, 0, __OBJS2BYTES__(nInstVars));
+ /*
+ * knowing that nil is 0
+ */
+ memset(__InstPtr(newString)->i_instvars, 0, __OBJS2BYTES__(nInstVars));
# else
- op = __InstPtr(newString)->i_instvars;
- do {
- *op++ = nil;
- } while (--nInstVars);
+ op = __InstPtr(newString)->i_instvars;
+ do {
+ *op++ = nil;
+ } while (--nInstVars);
# endif /* !FAST_MEMSET */
# endif
- }
-
- /*
- * fill with spaces
- */
-# ifdef FAST_MEMSET
- memset(cp, ' ', len);
- *(cp + len) = '\0';
-# else
- while (len >= 8) {
-# ifdef INT64
- ((INT64 *)cp)[0] = 0x2020202020202020L;
-# else
- ((int *)cp)[0] = 0x20202020;
- ((int *)cp)[1] = 0x20202020;
-# endif
- cp += 8;
- len -= 8;
- }
- while (len--)
- *cp++ = ' ';
- *cp = '\0';
-# endif /* !FAST_MEMSET */
- RETURN (newString);
- }
+ }
+ goto fillIt;
+ }
}
fail: ;;
#endif /* not __SCHTEAM__ */
@@ -307,16 +288,16 @@
use error handling in superclass
"
(anInteger < 0) ifTrue:[
- "
- the argument is negative,
- "
- self argumentError:'bad (negative) argument to new:' with:anInteger.
- ^ nil
+ "
+ the argument is negative,
+ "
+ self argumentError:'bad (negative) argument to new:' with:anInteger.
+ ^ nil
].
^ (super basicNew:anInteger+1) atAllPut:(Character space)
- "Modified: / 14-08-2018 / 10:53:27 / Claus Gittinger"
+ "Modified: / 24-03-2019 / 10:07:43 / Claus Gittinger"
!
new:n
@@ -373,65 +354,67 @@
REGISTER OBJ *op;
int nInstVars, instsize;
+ // fetch first; check later
+ // (if not a smallInteger, value will be ignored anyway)
+ len = __intVal(anInteger);
+ instsize = OHDR_SIZE + len + 1;
if (__isSmallInteger(anInteger)) {
- len = __intVal(anInteger);
- if (len >= 0) {
- instsize = OHDR_SIZE + len + 1;
- if (self == String) {
- if (__CanDoQuickNew(instsize)) { /* OBJECT ALLOCATION */
- /*
- * the most common case
- */
- __qCheckedNew(newString, instsize);
- __InstPtr(newString)->o_class = self; /* no need for PROTECT - there was no GC */
- __qSTORE(newString, self);
-
- cp = __stringVal(newString);
- cp[len] = '\0';
- RETURN (newString);
- }
- nInstVars = 0;
- } else {
- nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars);
- instsize += __OBJS2BYTES__(nInstVars);
- }
-
- __PROTECT_CONTEXT__;
- __qNew(newString, instsize); /* OBJECT ALLOCATION */
- __UNPROTECT_CONTEXT__;
-
- if (newString == nil) goto fail;
-
- __InstPtr(newString)->o_class = self;
- __qSTORE(newString, self);
-
- if (nInstVars) {
- /*
- * nil-out instvars
- */
+ if (len >= 0) {
+ if (self == String) {
+ if (__CanDoQuickNew(instsize)) { /* OBJECT ALLOCATION */
+ /*
+ * the most common case
+ */
+ __qCheckedNew(newString, instsize);
+ __InstPtr(newString)->o_class = self; /* no need for PROTECT - there was no GC */
+ __qSTORE(newString, self);
+
+ cp = __stringVal(newString);
+ cp[len] = '\0';
+ RETURN (newString);
+ }
+ nInstVars = 0;
+ } else {
+ nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars);
+ instsize += __OBJS2BYTES__(nInstVars);
+ }
+
+ __PROTECT_CONTEXT__;
+ __qNew(newString, instsize); /* OBJECT ALLOCATION */
+ __UNPROTECT_CONTEXT__;
+
+ if (newString == nil) goto fail;
+
+ __InstPtr(newString)->o_class = self;
+ __qSTORE(newString, self);
+
+ if (nInstVars) {
+ /*
+ * nil-out instvars
+ */
# if defined(memset4)
- memset4(__InstPtr(newString)->i_instvars, nil, nInstVars);
+ memset4(__InstPtr(newString)->i_instvars, nil, nInstVars);
# else
# if defined(FAST_MEMSET) && ! defined(NEGATIVE_ADDRESSES)
- /*
- * knowing that nil is 0
- */
- memset(__InstPtr(newString)->i_instvars, 0, __OBJS2BYTES__(nInstVars));
+ /*
+ * knowing that nil is 0
+ */
+ memset(__InstPtr(newString)->i_instvars, 0, __OBJS2BYTES__(nInstVars));
# else
- op = __InstPtr(newString)->i_instvars;
- do {
- *op++ = nil;
- } while (--nInstVars);
+ op = __InstPtr(newString)->i_instvars;
+ do {
+ *op++ = nil;
+ } while (--nInstVars);
# endif
# endif
- cp = __stringVal(newString) + __OBJS2BYTES__(nInstVars);
- } else {
- cp = __stringVal(newString);
- }
-
- *(cp + len) = '\0';
- RETURN (newString);
- }
+ cp = __stringVal(newString) + __OBJS2BYTES__(nInstVars);
+ } else {
+ cp = __stringVal(newString);
+ }
+
+ cp[len] = '\0';
+ RETURN (newString);
+ }
}
fail: ;;
#endif /* not __SCHTEAM__ */
@@ -441,11 +424,11 @@
use error handling in superclass
"
(anInteger < 0) ifTrue:[
- "
- the argument is negative,
- "
- self argumentError:'bad (negative) argument to new:' with:anInteger.
- ^ nil
+ "
+ the argument is negative,
+ "
+ self argumentError:'bad (negative) argument to new:' with:anInteger.
+ ^ nil
].
^ self basicNew:anInteger
@@ -454,7 +437,7 @@
String uninitializedNew:100
"
- "Modified: / 14-08-2018 / 10:53:17 / Claus Gittinger"
+ "Modified: / 24-03-2019 / 10:08:04 / Claus Gittinger"
! !
!String class methodsFor:'Compatibility-Dolphin'!
@@ -544,7 +527,6 @@
-
!String class methodsFor:'queries'!
defaultPlatformClass
@@ -567,8 +549,6 @@
-
-
!String methodsFor:'accessing'!
at:index
@@ -4861,7 +4841,6 @@
"Modified (comment): / 01-05-2017 / 14:05:41 / cg"
! !
-
!String methodsFor:'substring searching'!
caseInsensitiveIndexOfSubCollection:aSubString startingAt:startIndex ifAbsent:exceptionValue
@@ -5167,7 +5146,6 @@
! !
-
!String class methodsFor:'documentation'!
version