--- a/ByteArray.st Thu Jul 31 11:57:25 2014 +0200
+++ b/ByteArray.st Thu Jul 31 13:09:17 2014 +0200
@@ -2793,6 +2793,40 @@
!ByteArray methodsFor:'queries'!
+containsNon7BitAscii
+ "return true, if any byte in the receiver has the 7th bit on.
+ This my look as a too specific operation to be put here,
+ put it is very helpful for UTF8 string reading (Java class reader),
+ to quickly determine, if UTF8 decoding is needed or not.
+ As most strings in a class fiel are in fact only containing 7bit ascii,
+ this should speedup class file reading considerably"
+
+%{
+ REGISTER unsigned char *cp;
+ REGISTER unsigned char *endP;
+
+ if (__isByteArray(self)) {
+ cp = &(__ByteArrayInstPtr(self)->ba_element[0]);
+ endP = cp + __ByteArraySize(self);
+ while (cp+4 < endP) {
+ if ( ((unsigned int *)cp)[0] & 0x80808080) RETURN( true );
+ cp += 4;
+ }
+ while (cp < endP) {
+ if (*cp++ & 0x80) RETURN( true );
+ }
+ RETURN ( false );
+ }
+%}
+.
+ ^ self contains:[:b | b bitTest:16r80].
+
+ "
+ #[1 2 3 1 2 3 1 2 127 ] containsNon7BitAscii
+ #[1 2 3 1 2 3 1 2 250 251 250 251 255] containsNon7BitAscii
+ "
+!
+
max
"return the maximum value in the receiver -
redefined to speedup image processing and sound-player
@@ -3059,10 +3093,10 @@
!ByteArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.216 2014-07-25 21:52:59 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.217 2014-07-31 11:09:17 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.216 2014-07-25 21:52:59 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.217 2014-07-31 11:09:17 cg Exp $'
! !