#TUNING by cg
authorClaus Gittinger <cg@exept.de>
Wed, 27 Mar 2019 15:38:08 +0100
changeset 23986 27dd00ebc6bd
parent 23985 5dffbe3433bc
child 23987 bba7ed9be3c1
#TUNING by cg class: ReadStream changed: #next reading from a 32bit string stream
ReadStream.st
--- a/ReadStream.st	Wed Mar 27 14:55:09 2019 +0100
+++ b/ReadStream.st	Wed Mar 27 15:38:08 2019 +0100
@@ -231,14 +231,17 @@
     REGISTER INT pos;
     unsigned ch;
     OBJ coll, p, l;
-
-    coll = __INST(collection);
+    INT _readLimit;
+    
     p = __INST(position);
     l = __INST(readLimit);
+    coll = __INST(collection);
 
+    // fetch first; check later
+    pos = __intVal(p);
+    _readLimit = __intVal(l);
     if (__isNonNilObject(coll) && __bothSmallInteger(p, l)) {
-        pos = __intVal(p);
-        if (pos >= 0 && pos < __intVal(l)) {
+        if ((pos >= 0) && (pos < _readLimit)) {
             OBJ cls, ret;
 
             cls = __qClass(coll);
@@ -263,6 +266,13 @@
                     __INST(position) = __mkSmallInteger(pos+1);
                     RETURN ( ret );
                 }
+            } else if (cls == @global(Unicode32String)) {
+                if (pos < __unicode32StringSize(coll)) {
+                    ch = __unicode32StringVal(coll)[pos];
+                    ret = __MKUCHARACTER(ch);
+                    __INST(position) = __mkSmallInteger(pos+1);
+                    RETURN ( ret );
+                }
             } else if (cls == @global(Array)) {
                 if (pos < __arraySize(coll)) {
                     ret = __ArrayInstPtr(coll)->a_element[pos];
@@ -277,6 +287,8 @@
     position := position + 1.
     ret := collection at:position.
     ^ ret
+
+    "Modified: / 27-03-2019 / 15:34:48 / Claus Gittinger"
 !
 
 next:count