Changeset 24873 in webkit for trunk/JavaScriptCore/kjs/string_object.cpp
- Timestamp:
- Aug 4, 2007, 10:20:35 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/string_object.cpp
r24633 r24873 314 314 } 315 315 316 static JSValue *replace(ExecState *exec, const UString &source, JSValue *pattern, JSValue *replacement) 317 { 316 static JSValue *replace(ExecState *exec, StringImp* sourceVal, JSValue *pattern, JSValue *replacement) 317 { 318 UString source = sourceVal->value(); 318 319 JSObject *replacementFunction = 0; 319 320 UString replacementString; … … 366 367 367 368 args.append(jsNumber(completeMatchStart)); 368 args.append( jsString(source));369 args.append(sourceVal); 369 370 370 371 substitutedReplacement = replacementFunction->call(exec, exec->dynamicInterpreter()->globalObject(), … … 390 391 391 392 UString result; 393 392 394 if (sourceRanges) 393 395 result = source.spliceSubstringsWithSeparators(sourceRanges, sourceRangeCount, replacements, replacementCount); … … 395 397 delete [] sourceRanges; 396 398 delete [] replacements; 399 400 if (result == source) 401 return sourceVal; 397 402 398 403 return jsString(result); … … 405 410 // Do the replacement 406 411 if (matchPos == -1) 407 return jsString(source);412 return sourceVal; 408 413 409 414 if (replacementFunction) { … … 412 417 args.append(jsString(source.substr(matchPos, matchLen))); 413 418 args.append(jsNumber(matchPos)); 414 args.append( jsString(source));419 args.append(sourceVal); 415 420 416 421 replacementString = replacementFunction->call(exec, exec->dynamicInterpreter()->globalObject(), … … 563 568 } 564 569 case Replace: 565 result = replace(exec, s, a0, a1); 570 StringImp* sVal = thisObj->inherits(&StringInstance::info) ? 571 static_cast<StringInstance*>(thisObj)->internalValue() : 572 static_cast<StringImp*>(jsString(s)); 573 574 result = replace(exec, sVal, a0, a1); 566 575 break; 567 576 case Slice:
Note:
See TracChangeset
for help on using the changeset viewer.