Array.st
changeset 4122 7e3b6b267c06
parent 4062 4959de96b06f
child 4130 662554f2a37c
equal deleted inserted replaced
4121:4fbe619d6047 4122:7e3b6b267c06
   447      Reimplemented for speed if receiver is an Array.
   447      Reimplemented for speed if receiver is an Array.
   448      (since the inherited copyWith uses replaceFromTo:, which is also
   448      (since the inherited copyWith uses replaceFromTo:, which is also
   449       tuned, it is questionable, if we need this)"
   449       tuned, it is questionable, if we need this)"
   450 
   450 
   451 %{  /* NOCONTEXT */
   451 %{  /* NOCONTEXT */
   452     OBJ nObj, element;
   452     OBJ nObj;
   453     unsigned int sz;
   453     unsigned int sz;
   454     unsigned int nIndex;
   454     unsigned int nIndex;
   455     REGISTER OBJ *srcP, *dstP;
   455     REGISTER OBJ *srcP, *dstP;
   456     REGISTER int spc;
   456     REGISTER int spc;
   457 
   457 
   466 	    __STORE(nObj, Array);
   466 	    __STORE(nObj, Array);
   467 
   467 
   468 	    nIndex = __BYTES2OBJS__(sz - OHDR_SIZE - sizeof(OBJ));
   468 	    nIndex = __BYTES2OBJS__(sz - OHDR_SIZE - sizeof(OBJ));
   469 	    /* 
   469 	    /* 
   470 	     * sorry: 
   470 	     * sorry: 
   471 	     * cannot use bcopy, since we must take care of stores ... 
   471 	     *   cannot use bcopy, since we must take care of stores ... 
   472 	     * could check for: notRemembered + inOld + notLifoRem
   472 	     *   could check for: notRemembered + inOld + notLifoRem
   473 	     *                  + not incrGCRunning
   473 	     *                  + not incrGCRunning
   474 	     * but copyWith: is not heavily used by real programmers ...
   474 	     * but: copyWith is not heavily used by real programmers ...
   475 	     */
   475 	     */
   476 	    spc = __qSpace(nObj);
   476 	    spc = __qSpace(nObj);
   477 	    srcP = __ArrayInstPtr(self)->a_element;
   477 	    srcP = __ArrayInstPtr(self)->a_element;
   478 	    dstP = __ArrayInstPtr(nObj)->a_element;
   478 	    dstP = __ArrayInstPtr(nObj)->a_element;
   479 
   479 
   480 #ifdef UNROLL_LOOPS
   480 #ifdef UNROLL_LOOPS
   481 	    while (nIndex >= 4) {
   481 	    while (nIndex >= 4) {
       
   482     		OBJ element;
       
   483 
   482 		element = srcP[0];
   484 		element = srcP[0];
   483 		dstP[0] = element;
   485 		dstP[0] = element;
   484 		__STORE_SPC(nObj, element, spc);
   486 		__STORE_SPC(nObj, element, spc);
   485 		element = srcP[1];
   487 		element = srcP[1];
   486 		dstP[1] = element;
   488 		dstP[1] = element;
   495 		dstP += 4;
   497 		dstP += 4;
   496 		nIndex -= 4;
   498 		nIndex -= 4;
   497 	    }
   499 	    }
   498 #endif
   500 #endif
   499 	    while (nIndex--) {
   501 	    while (nIndex--) {
       
   502     		OBJ element;
       
   503 
   500 		element = *srcP++;
   504 		element = *srcP++;
   501 		*dstP++ = element;
   505 		*dstP++ = element;
   502 		__STORE_SPC(nObj, element, spc);
   506 		__STORE_SPC(nObj, element, spc);
   503 	    }
   507 	    }
   504 	    *dstP = something;
   508 	    *dstP = something;
   525     ^ aCollection
   529     ^ aCollection
   526 !
   530 !
   527 
   531 
   528 do:aBlock
   532 do:aBlock
   529     "evaluate the argument, aBlock for each element in the collection.
   533     "evaluate the argument, aBlock for each element in the collection.
   530      - reimplemented for speed"
   534      - reimplemented for speed, since this is used by many higher
       
   535        level collections"
   531 
   536 
   532     | sz "{ Class: SmallInteger }"|
   537     | sz "{ Class: SmallInteger }"|
   533 
   538 
   534     sz := self size.
   539     sz := self size.
   535 %{
   540 %{
   744 !
   749 !
   745 
   750 
   746 from:start to:stop do:aBlock
   751 from:start to:stop do:aBlock
   747     "evaluate the argument, aBlock for the elements starting at index start
   752     "evaluate the argument, aBlock for the elements starting at index start
   748      up to (and including) stop in the collection.
   753      up to (and including) stop in the collection.
   749      - reimplemented for speed"
   754      - reimplemented for speed, since this is used by many higher
       
   755        level collections"
   750 
   756 
   751 %{
   757 %{
   752     REGISTER OBJFUNC codeVal;
   758     REGISTER OBJFUNC codeVal;
   753     REGISTER int index;
   759     REGISTER int index;
   754     REGISTER OBJ rHome;
   760     REGISTER OBJ rHome;
  2315 ! !
  2321 ! !
  2316 
  2322 
  2317 !Array class methodsFor:'documentation'!
  2323 !Array class methodsFor:'documentation'!
  2318 
  2324 
  2319 version
  2325 version
  2320     ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.112 1999-03-19 20:42:23 cg Exp $'
  2326     ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.113 1999-04-25 12:40:20 cg Exp $'
  2321 ! !
  2327 ! !