--- a/CRCStream.st Fri Mar 22 13:56:20 2019 +0100
+++ b/CRCStream.st Sat Mar 23 11:48:07 2019 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"{ Package: 'stx:libbasic2' }"
"{ NameSpace: Smalltalk }"
@@ -213,15 +211,24 @@
"add the hash of anObject to the computed hash so far."
%{
+ int len, offs;
+
+ // fetch first - check later
+ len = __intVal(count);
+ offs = __intVal(start) - 1;
+
if (__bothSmallInteger(count, start)) {
- int len, offs;
int objSize;
unsigned char *extPtr;
- len = __intVal(count);
- offs = __intVal(start) - 1;
-
- if (__isExternalBytesLike(anObject)) {
+ // the most common first
+ if (__isStringLike(anObject)) {
+ objSize = __stringSize(anObject);
+ extPtr = (unsigned char *)__stringVal(anObject);
+ } else if (__isByteArray(anObject)) {
+ objSize = __byteArraySize(anObject);
+ extPtr = (unsigned char *)__byteArrayVal(anObject);
+ } else if (__isExternalBytesLike(anObject)) {
OBJ sz = __externalBytesSize(anObject);
extPtr = (unsigned char *)__externalBytesAddress(anObject);
@@ -260,9 +267,8 @@
unsigned char *cp = extPtr+offs;
unsigned int n = len;
- if (__isSmallInteger(__INST(crc))) {
- _crc = (unsigned int) (__intVal( __INST(crc) ));
- } else {
+ _crc = (unsigned int) (__intVal( __INST(crc) ));
+ if (!__isSmallInteger(__INST(crc))) {
_crc = __unsignedLongIntVal( __INST(crc) );
}
@@ -347,7 +353,7 @@
self error:'invalid argument'
"Created: / 09-01-2012 / 16:48:35 / cg"
- "Modified: / 16-03-2019 / 23:58:21 / Claus Gittinger"
+ "Modified: / 23-03-2019 / 10:10:07 / Claus Gittinger"
! !
!CRCStream class methodsFor:'documentation'!