#TUNING by stefan
authorStefan Vogel <sv@exept.de>
Thu, 16 Feb 2017 20:15:32 +0100
changeset 21465 853e279fcd9e
parent 21464 bc7542a5c194
child 21466 17c794d37c87
#TUNING by stefan class: ByteArray added: #isEmpty #notEmpty use primitive code for ImmutableByteArray
ByteArray.st
--- a/ByteArray.st	Thu Feb 16 20:15:06 2017 +0100
+++ b/ByteArray.st	Thu Feb 16 20:15:32 2017 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
@@ -3212,6 +3214,22 @@
 
 !
 
+isEmpty
+    "return true if the receiver is empty (i.e. if size == 0)
+     Redefined here for performance"
+
+%{  /* NOCONTEXT */
+#ifndef __SCHTEAM__
+    if (__isByteArrayLike(self)) {
+        RETURN ( (__byteArraySize(self) == 0) ? true : false);
+    }
+#endif /* ! __SCHTEAM__ */
+%}.
+    ^ self size == 0
+
+    "Created: / 16-02-2017 / 15:02:03 / stefan"
+!
+
 isLiteral
     "return true, if the receiver can be used as a literal constant in ST syntax
      (i.e. can be used in constant arrays)"
@@ -3223,6 +3241,22 @@
     ^ self class == ByteArray
 
     "Modified: 22.4.1996 / 12:55:30 / cg"
+!
+
+notEmpty
+    "return true if the receiver is not empty (i.e. if size ~~ 0)
+     Redefined here for performance"
+
+%{  /* NOCONTEXT */
+#ifndef __SCHTEAM__
+    if (__isByteArrayLike(self)) {
+        RETURN ( (__byteArraySize(self) != 0) ? true : false);
+    }
+#endif /* ! __SCHTEAM__ */
+%}.
+    ^ self size ~~ 0
+
+    "Created: / 16-02-2017 / 15:02:36 / stefan"
 ! !