Changeset 10182 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Aug 14, 2005, 9:41:47 AM (20 years ago)
Author:
darin
Message:

Reviewed by Maciej.

  • kjs/internal.h: Removed the copy constructor and assignment operator for LabelStack. They were unused, and the implementations had bugs; I removed them rather than fixing them. Also removed the clear function, since that was only needed to help the assignment operator share code with the destructor, and was not efficient enough for the destructor. (KJS::LabelStack::~LabelStack): Made this inline. Also used an efficient implementation that's nice and fast when the stack is empty, better than the old clear() function which used to keep updating and refetching "tos" each time through the loop. (KJS::LabelStack::pop): Made this inline.
  • kjs/internal.cpp: Deleted the now-inline functions and the obsolete functions. Also deleted a commented-out line of code.
Location:
trunk/JavaScriptCore/kjs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/internal.cpp

    r10178 r10182  
    261261// ------------------------------ LabelStack -----------------------------------
    262262
    263 LabelStack::LabelStack(const LabelStack &other)
    264 {
    265   tos = 0;
    266   *this = other;
    267 }
    268 
    269 LabelStack &LabelStack::operator=(const LabelStack &other)
    270 {
    271   clear();
    272   tos = 0;
    273   StackElem *cur = 0;
    274   StackElem *se = other.tos;
    275   while (se) {
    276     StackElem *newPrev = new StackElem;
    277     newPrev->prev = 0;
    278     newPrev->id = se->id;
    279     if (cur)
    280       cur->prev = newPrev;
    281     else
    282       tos = newPrev;
    283     cur = newPrev;
    284     se = se->prev;
    285   }
    286   return *this;
    287 }
    288 
    289263bool LabelStack::push(const Identifier &id)
    290264{
     
    309283
    310284  return false;
    311 }
    312 
    313 void LabelStack::pop()
    314 {
    315   if (tos) {
    316     StackElem *prev = tos->prev;
    317     delete tos;
    318     tos = prev;
    319   }
    320 }
    321 
    322 LabelStack::~LabelStack()
    323 {
    324   clear();
    325 }
    326 
    327 void LabelStack::clear()
    328 {
    329   StackElem *prev;
    330 
    331   while (tos) {
    332     prev = tos->prev;
    333     delete tos;
    334     tos = prev;
    335   }
    336285}
    337286
     
    426375  ProgramNode *prog = progNode;
    427376  progNode = 0;
    428 //  sid = -1;
    429377
    430378  if (parseError || lexError) {
  • trunk/JavaScriptCore/kjs/internal.h

    r10178 r10182  
    140140    ~LabelStack();
    141141
    142     LabelStack(const LabelStack &other);
    143     LabelStack &operator=(const LabelStack &other);
    144 
    145142    /**
    146143     * If id is not empty and is not in the stack already, puts it on top of
     
    166163   
    167164  private:
     165    LabelStack(const LabelStack &other);
     166    LabelStack &operator=(const LabelStack &other);
     167
    168168    struct StackElem {
    169169      Identifier id;
     
    172172
    173173    StackElem *tos;
    174     void clear();
    175174    int iterationDepth;
    176175    int switchDepth;
     
    409408#endif
    410409
     410inline LabelStack::~LabelStack()
     411{
     412    StackElem *prev;
     413    for (StackElem *e = tos; e; e = prev) {
     414        prev = e->prev;
     415        delete e;
     416    }
     417}
     418
     419inline void LabelStack::pop()
     420{
     421    if (StackElem *e = tos) {
     422        tos = e->prev;
     423        delete e;
     424    }
     425}
     426
    411427} // namespace
    412428
Note: See TracChangeset for help on using the changeset viewer.