VirtualBox

Changeset 101927 in vbox


Ignore:
Timestamp:
Nov 7, 2023 11:00:14 AM (15 months ago)
Author:
vboxsync
Message:

libs/xpcom: Remove unused code in nsDeque.{cpp,h}, bugref:10545

Location:
trunk/src/libs/xpcom18a4
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp

    r101924 r101927  
    15251525    , mPeerID(aPeerID)
    15261526    , mCachedISupports(0)
    1527     , mRefCntLevels(0)
     1527    , mRefCntLevels()
    15281528    {}
    15291529
  • trunk/src/libs/xpcom18a4/xpcom/ds/nsDeque.cpp

    r58038 r101927  
    7878/**
    7979 * Standard constructor
    80  * @param deallocator, called by Erase and ~nsDeque
    81  */
    82 nsDeque::nsDeque(nsDequeFunctor* aDeallocator) {
     80 */
     81nsDeque::nsDeque() {
    8382  MOZ_COUNT_CTOR(nsDeque);
    84   mDeallocator=aDeallocator;
    8583  mOrigin=mSize=0;
    8684  mData=mBuffer; // don't allocate space until you must
     
    9593  MOZ_COUNT_DTOR(nsDeque);
    9694
    97 #ifdef DEBUG_rickg
    98   char buffer[30];
    99   printf("Capacity: %i\n", mCapacity);
    100 
    101   static int mCaps[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    102   switch(mCapacity) {
    103     case 4:     mCaps[0]++; break;
    104     case 8:     mCaps[1]++; break;
    105     case 16:    mCaps[2]++; break;
    106     case 32:    mCaps[3]++; break;
    107     case 64:    mCaps[4]++; break;
    108     case 128:   mCaps[5]++; break;
    109     case 256:   mCaps[6]++; break;
    110     case 512:   mCaps[7]++; break;
    111     case 1024:  mCaps[8]++; break;
    112     case 2048:  mCaps[9]++; break;
    113     case 4096:  mCaps[10]++; break;
    114     default:
    115       break;
    116   }
    117 #endif
    118 
    11995  Erase();
    12096  if (mData && (mData!=mBuffer)) {
     
    12298  }
    12399  mData=0;
    124   SetDeallocator(0);
    125 }
    126 
    127 /**
    128  * Set the functor to be called by Erase()
    129  * The deque owns the functor.
    130  *
    131  * @param   aDeallocator functor object for use by Erase()
    132  */
    133 void nsDeque::SetDeallocator(nsDequeFunctor* aDeallocator){
    134   if (mDeallocator) {
    135     delete mDeallocator;
    136   }
    137   mDeallocator=aDeallocator;
    138100}
    139101
     
    158120 */
    159121nsDeque& nsDeque::Erase() {
    160   if (mDeallocator && mSize) {
    161     ForEach(*mDeallocator);
    162   }
    163122  return Empty();
    164123}
     
    358317}
    359318
    360 /**
    361  * Create and return an iterator pointing to
    362  * the beginning of the queue. Note that this
    363  * takes the circular buffer semantics into account.
    364  *
    365  * @return  new deque iterator, init'ed to 1st item
    366  */
    367 nsDequeIterator nsDeque::Begin() const{
    368   return nsDequeIterator(*this, 0);
    369 }
    370 
    371 /**
    372  * Create and return an iterator pointing to
    373  * the last item in the deque.
    374  * Note that this takes the circular buffer semantics
    375  * into account.
    376  *
    377  * @return  new deque iterator, init'ed to the last item
    378  */
    379 nsDequeIterator nsDeque::End() const{
    380   return nsDequeIterator(*this, mSize - 1);
    381 }
    382 
    383 void* nsDeque::Last() const {
    384   return End().GetCurrent();
    385 }
    386 
    387 /**
    388  * Call this method when you want to iterate all the
    389  * members of the container, passing a functor along
    390  * to call your code.
    391  *
    392  * @param   aFunctor object to call for each member
    393  * @return  *this
    394  */
    395 void nsDeque::ForEach(nsDequeFunctor& aFunctor) const{
    396   for (PRInt32 i=0; i<mSize; i++) {
    397     aFunctor(ObjectAt(i));
    398   }
    399 }
    400 
    401 /**
    402  * Call this method when you want to iterate all the
    403  * members of the container, calling the functor you
    404  * passed with each member. This process will interrupt
    405  * if your function returns non 0 to this method.
    406  *
    407  * @param   aFunctor object to call for each member
    408  * @return  first nonzero result of aFunctor or 0.
    409  */
    410 const void* nsDeque::FirstThat(nsDequeFunctor& aFunctor) const{
    411   for (PRInt32 i=0; i<mSize; i++) {
    412     void* obj=aFunctor(ObjectAt(i));
    413     if (obj) {
    414       return obj;
    415     }
    416   }
    417   return 0;
    418 }
    419 
    420 /******************************************************
    421  * Here comes the nsDequeIterator class...
    422  ******************************************************/
    423 
    424 /**
    425  * DequeIterator is an object that knows how to iterate (forward and backward)
    426  * through a Deque. Normally, you don't need to do this, but there are some special
    427  * cases where it is pretty handy, so here you go.
    428  *
    429  * This is a standard dequeiterator constructor
    430  *
    431  * @param   aQueue is the deque object to be iterated
    432  * @param   aIndex is the starting position for your iteration
    433  */
    434 nsDequeIterator::nsDequeIterator(const nsDeque& aQueue, int aIndex)
    435 : mIndex(aIndex),
    436   mDeque(aQueue)
    437 {
    438 }
    439 
    440 /**
    441  * Create a copy of a DequeIterator
    442  *
    443  * @param   aCopy is another iterator to copy from
    444  */
    445 nsDequeIterator::nsDequeIterator(const nsDequeIterator& aCopy)
    446 : mIndex(aCopy.mIndex),
    447   mDeque(aCopy.mDeque)
    448 {
    449 }
    450 
    451 /**
    452  * Moves iterator to first element in deque
    453  * @return  *this
    454  */
    455 nsDequeIterator& nsDequeIterator::First(){
    456   mIndex=0;
    457   return *this;
    458 }
    459 
    460 /**
    461  * Standard assignment operator for dequeiterator
    462  *
    463  * @param   aCopy is an iterator to be copied from
    464  * @return  *this
    465  */
    466 nsDequeIterator& nsDequeIterator::operator=(const nsDequeIterator& aCopy) {
    467   NS_ASSERTION(&mDeque==&aCopy.mDeque,"you can't change the deque that an interator is iterating over, sorry.");
    468   mIndex=aCopy.mIndex;
    469   return *this;
    470 }
    471 
    472 /**
    473  * preform ! operation against to iterators to test for equivalence
    474  * (or lack thereof)!
    475  *
    476  * @param   aIter is the object to be compared to
    477  * @return  TRUE if NOT equal.
    478  */
    479 PRBool nsDequeIterator::operator!=(nsDequeIterator& aIter) {
    480   return PRBool(!this->operator==(aIter));
    481 }
    482 
    483 /**
    484  * Compare two iterators for increasing order.
    485  *
    486  * @param   aIter is the other iterator to be compared to
    487  * @return  TRUE if this object points to an element before
    488  *          the element pointed to by aIter.
    489  *          FALSE if this and aIter are not iterating over the same deque.
    490  */
    491 PRBool nsDequeIterator::operator<(nsDequeIterator& aIter) {
    492   return PRBool(((mIndex<aIter.mIndex) && (&mDeque==&aIter.mDeque)));
    493 }
    494 
    495 /**
    496  * Compare two iterators for equivalence.
    497  *
    498  * @param   aIter is the other iterator to be compared to
    499  * @return  TRUE if EQUAL
    500  */
    501 PRBool nsDequeIterator::operator==(nsDequeIterator& aIter) {
    502   return PRBool(((mIndex==aIter.mIndex) && (&mDeque==&aIter.mDeque)));
    503 }
    504 
    505 /**
    506  * Compare two iterators for non strict decreasing order.
    507  *
    508  * @param   aIter is the other iterator to be compared to
    509  * @return  TRUE if this object points to the same element, or
    510  *          an element after the element pointed to by aIter.
    511  *          FALSE if this and aIter are not iterating over the same deque.
    512  */
    513 PRBool nsDequeIterator::operator>=(nsDequeIterator& aIter) {
    514   return PRBool(((mIndex>=aIter.mIndex) && (&mDeque==&aIter.mDeque)));
    515 }
    516 
    517 /**
    518  * Pre-increment operator
    519  *
    520  * @return  object at post-incremented index
    521  */
    522 void* nsDequeIterator::operator++() {
    523   NS_ASSERTION(mIndex<mDeque.mSize,
    524     "You have reached the end of the Internet."\
    525     "You have seen everything there is to see. Please go back. Now."
    526   );
    527 #ifndef TIMELESS_LIGHTWEIGHT
    528   if (mIndex>=mDeque.mSize) return 0;
    529 #endif
    530   return mDeque.ObjectAt(++mIndex);
    531 }
    532 
    533 /**
    534  * Post-increment operator
    535  *
    536  * @param   param is ignored
    537  * @return  object at pre-incremented index
    538  */
    539 void* nsDequeIterator::operator++(int) {
    540   NS_ASSERTION(mIndex<=mDeque.mSize,
    541     "You have already reached the end of the Internet."\
    542     "You have seen everything there is to see. Please go back. Now."
    543   );
    544 #ifndef TIMELESS_LIGHTWEIGHT
    545   if (mIndex>mDeque.mSize) return 0;
    546 #endif
    547   return mDeque.ObjectAt(mIndex++);
    548 }
    549 
    550 /**
    551  * Pre-decrement operator
    552  *
    553  * @return  object at pre-decremented index
    554  */
    555 void* nsDequeIterator::operator--() {
    556   NS_ASSERTION(mIndex>=0,
    557     "You have reached the beginning of the Internet."\
    558     "You have seen everything there is to see. Please go forward. Now."
    559   );
    560 #ifndef TIMELESS_LIGHTWEIGHT
    561   if (mIndex<0) return 0;
    562 #endif
    563   return mDeque.ObjectAt(--mIndex);
    564 }
    565 
    566 /**
    567  * Post-decrement operator
    568  *
    569  * @param   param is ignored
    570  * @return  object at post-decremented index
    571  */
    572 void* nsDequeIterator::operator--(int) {
    573   NS_ASSERTION(mIndex>=0,
    574     "You have already reached the beginning of the Internet."\
    575     "You have seen everything there is to see. Please go forward. Now."
    576   );
    577 #ifndef TIMELESS_LIGHTWEIGHT
    578   if (mIndex<0) return 0;
    579 #endif
    580   return mDeque.ObjectAt(mIndex--);
    581 }
    582 
    583 /**
    584  * Dereference operator
    585  * Note that the iterator floats, so you don't need to do:
    586  * <code>++iter; aDeque.PopFront();</code>
    587  * Unless you actually want your iterator to jump 2 spaces.
    588  *
    589  * Picture: [1 2I 3 4]
    590  * PopFront()
    591  * Picture: [2 3I 4]
    592  * Note that I still happily points to object at the second index
    593  *
    594  * @return  object at ith index
    595  */
    596 void* nsDequeIterator::GetCurrent() {
    597   NS_ASSERTION(mIndex<mDeque.mSize&&mIndex>=0,"Current is out of bounds");
    598 #ifndef TIMELESS_LIGHTWEIGHT
    599   if (mIndex>=mDeque.mSize||mIndex<0) return 0;
    600 #endif
    601   return mDeque.ObjectAt(mIndex);
    602 }
    603 
    604 /**
    605  * Call this method when you want to iterate all the
    606  * members of the container, passing a functor along
    607  * to call your code.
    608  *
    609  * @param   aFunctor object to call for each member
    610  * @return  *this
    611  */
    612 void nsDequeIterator::ForEach(nsDequeFunctor& aFunctor) const{
    613   mDeque.ForEach(aFunctor);
    614 }
    615 
    616 /**
    617  * Call this method when you want to iterate all the
    618  * members of the container, calling the functor you
    619  * passed with each member. This process will interrupt
    620  * if your function returns non 0 to this method.
    621  *
    622  * @param   aFunctor object to call for each member
    623  * @return  first nonzero result of aFunctor or 0.
    624  */
    625 const void* nsDequeIterator::FirstThat(nsDequeFunctor& aFunctor) const{
    626   return mDeque.FirstThat(aFunctor);
    627 }
  • trunk/src/libs/xpcom18a4/xpcom/ds/nsDeque.h

    r62266 r101927  
    5959#include "nscore.h"
    6060
    61 /**
    62  * The nsDequeFunctor class is used when you want to create
    63  * callbacks between the deque and your generic code.
    64  * Use these objects in a call to ForEach();
    65  *
    66  */
    67 
    68 class nsDequeFunctor{
    69 public:
    70   virtual void* operator()(void* anObject)=0;
    71 };
    72 
    7361/******************************************************
    7462 * Here comes the nsDeque class itself...
     
    8472 * The deque stores pointers to items.
    8573 */
    86 
    87 class nsDequeIterator;
    88 
    8974class NS_COM nsDeque {
    90   friend class nsDequeIterator;
    9175  public:
    92    nsDeque(nsDequeFunctor* aDeallocator);
     76   nsDeque();
    9377  ~nsDeque();
    9478
     
    169153  nsDeque& Erase();
    170154
    171   /**
    172    * Creates a new iterator, pointing to the first
    173    * item in the deque.
    174    *
    175    * @return  new dequeIterator
    176    */
    177   nsDequeIterator Begin() const;
    178 
    179   /**
    180    * Creates a new iterator, pointing to the last
    181    * item in the deque.
    182    *
    183    * @return  new dequeIterator
    184    */
    185   nsDequeIterator End() const;
    186 
    187   void* Last() const;
    188   /**
    189    * Call this method when you want to iterate all the
    190    * members of the container, passing a functor along
    191    * to call your code.
    192    *
    193    * @param   aFunctor object to call for each member
    194    * @return  *this
    195    */
    196   void ForEach(nsDequeFunctor& aFunctor) const;
    197 
    198   /**
    199    * Call this method when you want to iterate all the
    200    * members of the container, calling the functor you
    201    * passed with each member. This process will interrupt
    202    * if your function returns non 0 to this method.
    203    *
    204    * @param   aFunctor object to call for each member
    205    * @return  first nonzero result of aFunctor or 0.
    206    */
    207   const void* FirstThat(nsDequeFunctor& aFunctor) const;
    208 
    209   void SetDeallocator(nsDequeFunctor* aDeallocator);
    210 
    211155protected:
    212156  PRInt32         mSize;
    213157  PRInt32         mCapacity;
    214158  PRInt32         mOrigin;
    215   nsDequeFunctor* mDeallocator;
    216159  void*           mBuffer[8];
    217160  void**          mData;
    218161
    219162private:
    220 
    221   /**
    222    * Simple default constructor (PRIVATE)
    223    */
    224   nsDeque();
    225163
    226164  /**
     
    242180};
    243181
    244 /******************************************************
    245  * Here comes the nsDequeIterator class...
    246  ******************************************************/
    247 
    248 class nsDequeIterator {
    249 public:
    250   /**
    251    * DequeIterator is an object that knows how to iterate
    252    * (forward and backward) through a Deque. Normally,
    253    * you don't need to do this, but there are some special
    254    * cases where it is pretty handy.
    255    *
    256    * One warning: the iterator is not bound to an item,
    257    * it is bound to an index, so if you insert or remove
    258    * from the beginning while using an iterator
    259    * (which is not recommended) then the iterator will
    260    * point to a different item.  @see GetCurrent()
    261    *
    262    * Here you go.
    263    *
    264    * @param   aQueue is the deque object to be iterated
    265    * @param   aIndex is the starting position for your iteration
    266    */
    267   nsDequeIterator(const nsDeque& aQueue, int aIndex=0);
    268 
    269   /**
    270    * Create a copy of a DequeIterator
    271    *
    272    * @param   aCopy is another iterator to copy from
    273    */
    274   nsDequeIterator(const nsDequeIterator& aCopy);
    275 
    276   /**
    277    * Moves iterator to first element in the deque
    278    * @return  *this
    279    */
    280   nsDequeIterator& First();
    281 
    282   /**
    283    * Standard assignment operator for dequeiterator
    284    * @param   aCopy is another iterator to copy from
    285    * @return  *this
    286    */
    287   nsDequeIterator& operator=(const nsDequeIterator& aCopy);
    288 
    289   /**
    290    * preform ! operation against two iterators to test for equivalence
    291    * (or lack thereof)!
    292    *
    293    * @param   aIter is the object to be compared to
    294    * @return  TRUE if NOT equal.
    295    */
    296   PRBool operator!=(nsDequeIterator& aIter);
    297 
    298   /**
    299    * Compare two iterators for increasing order.
    300    *
    301    * @param   aIter is the other iterator to be compared to
    302    * @return  TRUE if this object points to an element before
    303    *          the element pointed to by aIter.
    304    *          FALSE if this and aIter are not iterating over
    305    *          the same deque.
    306    */
    307   PRBool operator<(nsDequeIterator& aIter);
    308 
    309   /**
    310    * Compare two iterators for equivalence.
    311    *
    312    * @param   aIter is the other iterator to be compared to
    313    * @return  TRUE if EQUAL
    314    */
    315   PRBool operator==(nsDequeIterator& aIter);
    316 
    317   /**
    318    * Compare two iterators for non strict decreasing order.
    319    *
    320    * @param   aIter is the other iterator to be compared to
    321    * @return  TRUE if this object points to the same element, or
    322    *          an element after the element pointed to by aIter.
    323    *          FALSE if this and aIter are not iterating over
    324    *          the same deque.
    325    */
    326   PRBool operator>=(nsDequeIterator& aIter);
    327 
    328   /**
    329    * Pre-increment operator
    330    * Iterator will advance one index towards the end.
    331    *
    332    * @return  object_at(++index)
    333    */
    334   void* operator++();
    335 
    336   /**
    337    * Post-increment operator
    338    * Iterator will advance one index towards the end.
    339    *
    340    * @param   param is ignored
    341    * @return  object_at(mIndex++)
    342    */
    343   void* operator++(int);
    344 
    345   /**
    346    * Pre-decrement operator
    347    * Iterator will advance one index towards the beginning.
    348    *
    349    * @return  object_at(--index)
    350    */
    351   void* operator--();
    352 
    353   /**
    354    * Post-decrement operator
    355    * Iterator will advance one index towards the beginning.
    356    *
    357    * @param   param is ignored
    358    * @return  object_at(index--)
    359    */
    360   void* operator--(int);
    361 
    362   /**
    363    * Retrieve the the iterator's notion of current node.
    364    *
    365    * Note that the iterator floats, so you don't need to do:
    366    * <code>++iter; aDeque.PopFront();</code>
    367    * Unless you actually want your iterator to jump 2 positions
    368    * relative to its origin.
    369    *
    370    * Picture: [1 2i 3 4]
    371    * PopFront()
    372    * Picture: [2 3i 4]
    373    * Note that I still happily points to object at the second index.
    374    *
    375    * @return  object at i'th index
    376    */
    377   void* GetCurrent();
    378 
    379   /**
    380    * Call this method when you want to iterate all the
    381    * members of the container, passing a functor along
    382    * to call your code.
    383    *
    384    * @param   aFunctor object to call for each member
    385    * @return  *this
    386    */
    387   void ForEach(nsDequeFunctor& aFunctor) const;
    388 
    389   /**
    390    * Call this method when you want to iterate all the
    391    * members of the container, calling the functor you
    392    * passed with each member. This process will interrupt
    393    * if your function returns non 0 to this method.
    394    *
    395    * @param   aFunctor object to call for each member
    396    * @return  first nonzero result of aFunctor or 0.
    397    */
    398   const void* FirstThat(nsDequeFunctor& aFunctor) const;
    399 
    400   protected:
    401 
    402   PRInt32         mIndex;
    403   const nsDeque&  mDeque;
    404 };
    405182#endif
  • trunk/src/libs/xpcom18a4/xpcom/tests/TestDeque.cpp

    r1 r101927  
    4040#include <stdio.h>
    4141
    42 /**************************************************************
    43   Now define the token deallocator class...
    44  **************************************************************/
    4542class _TestDeque {
    4643public:
     
    5451};
    5552static _TestDeque sTestDeque;
    56 
    57 class _Dealloc: public nsDequeFunctor {
    58   virtual void* operator()(void* aObject) {
    59     return 0;
    60   }
    61 };
    6253
    6354/**
     
    8172  int i=0;
    8273  int* temp;
    83   nsDeque theDeque(new _Dealloc); //construct a simple one...
     74  nsDeque theDeque; //construct a simple one...
    8475 
    8576  for (i=0;i<count;i++) { //initialize'em
     
    111102  int i=0;
    112103  int* temp;
    113   nsDeque secondDeque(new _Dealloc);
     104  nsDeque secondDeque;
    114105  /**
    115106   * Test 1. Origin near end, semi full, call Peek().
     
    146137
    147138nsresult _TestDeque::AssignFlaw() {
    148   nsDeque src(new _Dealloc),dest(new _Dealloc);
     139  nsDeque src, dest;
    149140  return NS_OK;
    150141}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette