Changeset 49365 in webkit for trunk/JavaScriptCore/runtime/RegExpConstructor.cpp
- Timestamp:
- Oct 8, 2009, 8:22:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/RegExpConstructor.cpp
r48836 r49365 91 91 */ 92 92 93 struct RegExpConstructorPrivate : FastAllocBase {94 // Global search cache / settings95 RegExpConstructorPrivate()96 : lastNumSubPatterns(0)97 , multiline(false)98 , lastOvectorIndex(0)99 {100 }101 102 const Vector<int, 32>& lastOvector() const { return ovector[lastOvectorIndex]; }103 Vector<int, 32>& lastOvector() { return ovector[lastOvectorIndex]; }104 Vector<int, 32>& tempOvector() { return ovector[lastOvectorIndex ? 0 : 1]; }105 void changeLastOvector() { lastOvectorIndex = lastOvectorIndex ? 0 : 1; }106 107 UString input;108 UString lastInput;109 Vector<int, 32> ovector[2];110 unsigned lastNumSubPatterns : 30;111 bool multiline : 1;112 unsigned lastOvectorIndex : 1;113 };114 115 93 RegExpConstructor::RegExpConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, RegExpPrototype* regExpPrototype) 116 94 : InternalFunction(&exec->globalData(), structure, Identifier(exec, "RegExp")) … … 122 100 // no. of arguments for constructor 123 101 putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly | DontDelete | DontEnum); 124 }125 126 /*127 To facilitate result caching, exec(), test(), match(), search(), and replace() dipatch regular128 expression matching through the performMatch function. We use cached results to calculate,129 e.g., RegExp.lastMatch and RegExp.leftParen.130 */131 void RegExpConstructor::performMatch(RegExp* r, const UString& s, int startOffset, int& position, int& length, int** ovector)132 {133 position = r->match(s, startOffset, &d->tempOvector());134 135 if (ovector)136 *ovector = d->tempOvector().data();137 138 if (position != -1) {139 ASSERT(!d->tempOvector().isEmpty());140 141 length = d->tempOvector()[1] - d->tempOvector()[0];142 143 d->input = s;144 d->lastInput = s;145 d->changeLastOvector();146 d->lastNumSubPatterns = r->numSubpatterns();147 }148 102 } 149 103
Note:
See TracChangeset
for help on using the changeset viewer.