ByteArray.st
changeset 2894 344aec8ba014
parent 2890 fa0418a0f896
child 2898 ec12723d8582
equal deleted inserted replaced
2893:8ba406da6b22 2894:344aec8ba014
   165 	    if (self == ByteArray) {
   165 	    if (self == ByteArray) {
   166 		/*
   166 		/*
   167 		 * the most common case
   167 		 * the most common case
   168 		 */
   168 		 */
   169 		instsize = OHDR_SIZE + nindexedinstvars;
   169 		instsize = OHDR_SIZE + nindexedinstvars;
   170 		if (__CanDoQuickNew(instsize)) {
   170 		if (__CanDoQuickNew(instsize)) {	/* OBJECT ALLOCATION */
   171 		    __qCheckedNew(newobj, instsize);
   171 		    __qCheckedNew(newobj, instsize);
   172 		    __InstPtr(newobj)->o_class = self;
   172 		    __InstPtr(newobj)->o_class = self;
   173 		    RETURN (newobj );
   173 		    RETURN (newobj );
   174 		}
   174 		}
   175 	    }
   175 	    }
   176 	    nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars);
   176 	    nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars);
   177 	    instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars) + nindexedinstvars;
   177 	    instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars) + nindexedinstvars;
   178 	    __PROTECT_CONTEXT__
   178 	    __PROTECT_CONTEXT__
   179 	    __qNew(newobj, instsize);
   179 	    __qNew(newobj, instsize);	/* OBJECT ALLOCATION */
   180 	    __UNPROTECT_CONTEXT__
   180 	    __UNPROTECT_CONTEXT__
   181 	    if (newobj != nil) {
   181 	    if (newobj != nil) {
   182 		__InstPtr(newobj)->o_class = self;
   182 		__InstPtr(newobj)->o_class = self;
   183 		__qSTORE(newobj, self);
   183 		__qSTORE(newobj, self);
   184 		if (nInstVars) {
   184 		if (nInstVars) {
  1305 	if ((index1 <= index2) && (index1 > 0)) {
  1305 	if ((index1 <= index2) && (index1 > 0)) {
  1306 	    if (index2 <= len) {
  1306 	    if (index2 <= len) {
  1307 		count = index2 - index1 + 1;
  1307 		count = index2 - index1 + 1;
  1308 		__PROTECT_CONTEXT__
  1308 		__PROTECT_CONTEXT__
  1309 		sz = OHDR_SIZE + count;
  1309 		sz = OHDR_SIZE + count;
  1310 		__qNew(newByteArray, sz);
  1310 		__qNew(newByteArray, sz);	/* OBJECT ALLOCATION */
  1311 		__UNPROTECT_CONTEXT__
  1311 		__UNPROTECT_CONTEXT__
  1312 		if (newByteArray != nil) {
  1312 		if (newByteArray != nil) {
  1313 		    __InstPtr(newByteArray)->o_class = ByteArray;
  1313 		    __InstPtr(newByteArray)->o_class = ByteArray;
  1314 		    dstp = __ByteArrayInstPtr(newByteArray)->ba_element;
  1314 		    dstp = __ByteArrayInstPtr(newByteArray)->ba_element;
  1315 		    srcp = __ByteArrayInstPtr(self)->ba_element + index1 - 1;
  1315 		    srcp = __ByteArrayInstPtr(self)->ba_element + index1 - 1;
  1447     REGISTER int repStartIndex;
  1447     REGISTER int repStartIndex;
  1448     int repStopIndex, count;
  1448     int repStopIndex, count;
  1449     REGISTER unsigned char *dst;
  1449     REGISTER unsigned char *dst;
  1450     OBJ cls;
  1450     OBJ cls;
  1451 
  1451 
       
  1452 #define NO_PRIM_BYTEARR
       
  1453 #ifndef NO_PRIM_BYTEARR
  1452     if (__isBytes(aCollection)
  1454     if (__isBytes(aCollection)
  1453      && __isBytes(self)
  1455      && __isBytes(self)
  1454      && __bothSmallInteger(start, stop)
  1456      && __bothSmallInteger(start, stop)
  1455      && __isSmallInteger(repStart)) {
  1457      && __isSmallInteger(repStart)) {
  1456         startIndex = __intVal(start) - 1;
  1458         startIndex = __intVal(start) - 1;
  1540                     }
  1542                     }
  1541                 }
  1543                 }
  1542             }
  1544             }
  1543         }
  1545         }
  1544     }
  1546     }
       
  1547 #endif
  1545 %}.
  1548 %}.
  1546     "
  1549     "
  1547      fall back in case of non-ByteArray argument,
  1550      fall back in case of non-ByteArray argument,
  1548      or for the error report if any index is invalid
  1551      or for the error report if any index is invalid
  1549     "
  1552     "
  2347 ! !
  2350 ! !
  2348 
  2351 
  2349 !ByteArray class methodsFor:'documentation'!
  2352 !ByteArray class methodsFor:'documentation'!
  2350 
  2353 
  2351 version
  2354 version
  2352     ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.84 1997-08-22 17:56:29 cg Exp $'
  2355     ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.85 1997-09-02 20:52:22 cg Exp $'
  2353 ! !
  2356 ! !