Ignore:
Timestamp:
Feb 9, 2008, 10:09:42 AM (17 years ago)
Author:
Darin Adler
Message:

Reviewed by Mitz.

We'll want to do this to every RefCounted class, one at a time.

  • kjs/nodes.h: (KJS::RegExpNode::RegExpNode): Use RegExp::create instead of new RegExp.
  • kjs/regexp.cpp: (KJS::RegExp::RegExp): Marked inline, set initial ref count to 1. (KJS::RegExp::create): Added. Calls new RegExp then adopts the initial ref.
  • kjs/regexp.h: Reformatted. Made the constructors private. Added static create functions that return objects already wrapped in PassRefPtr.
  • kjs/regexp_object.cpp: (KJS::regExpProtoFuncCompile): Use RegExp::create instead of new RegExp. (KJS::RegExpObjectImp::construct): Ditto.
  • kjs/string_object.cpp: (KJS::stringProtoFuncMatch): Ditto. (KJS::stringProtoFuncSearch): Ditto.
File:
1 edited

Legend:

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

    r30040 r30109  
    534534
    535535    UString u = s;
    536     RegExp* reg;
    537     RegExp* tmpReg = 0;
     536    RefPtr<RegExp> reg;
    538537    RegExpImp* imp = 0;
    539538    if (a0->isObject() && static_cast<JSObject *>(a0)->inherits(&RegExpImp::info)) {
     
    545544       *  replaced with the result of the expression new RegExp(regexp).
    546545       */
    547       reg = tmpReg = new RegExp(a0->toString(exec));
     546      reg = RegExp::create(a0->toString(exec));
    548547    }
    549548    RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalGlobalObject()->regExpConstructor());
    550549    int pos;
    551550    int matchLength;
    552     regExpObj->performMatch(reg, u, 0, pos, matchLength);
     551    regExpObj->performMatch(reg.get(), u, 0, pos, matchLength);
    553552    JSValue* result;
    554553    if (!(reg->global())) {
     
    566565        lastIndex = pos;
    567566        pos += matchLength == 0 ? 1 : matchLength;
    568         regExpObj->performMatch(reg, u, pos, pos, matchLength);
     567        regExpObj->performMatch(reg.get(), u, pos, pos, matchLength);
    569568      }
    570569      if (imp)
     
    579578      }
    580579    }
    581     delete tmpReg;
    582580    return result;
    583581}
     
    591589
    592590    UString u = s;
    593     RegExp* reg;
    594     RegExp* tmpReg = 0;
    595     if (a0->isObject() && static_cast<JSObject *>(a0)->inherits(&RegExpImp::info)) {
    596       reg = static_cast<RegExpImp *>(a0)->regExp();
     591    RefPtr<RegExp> reg;
     592    if (a0->isObject() && static_cast<JSObject*>(a0)->inherits(&RegExpImp::info)) {
     593      reg = static_cast<RegExpImp*>(a0)->regExp();
    597594    } else {
    598595      /*
     
    601598       *  replaced with the result of the expression new RegExp(regexp).
    602599       */
    603       reg = tmpReg = new RegExp(a0->toString(exec));
     600      reg = RegExp::create(a0->toString(exec));
    604601    }
    605602    RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalGlobalObject()->regExpConstructor());
    606603    int pos;
    607604    int matchLength;
    608     regExpObj->performMatch(reg, u, 0, pos, matchLength);
    609     delete tmpReg;
     605    regExpObj->performMatch(reg.get(), u, 0, pos, matchLength);
    610606    return jsNumber(pos);
    611607}
Note: See TracChangeset for help on using the changeset viewer.