#TUNING by cg
class: ReadStream
changed: #next
reading from a 32bit string stream
--- 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