Changeset 5436 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Nov 10, 2003, 8:31:34 AM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/array_object.cpp
r4792 r5436 280 280 { 281 281 ExecState *exec = execForCompareByStringForQSort; 282 return compare(Value(*(ValueImp **)a).toString(exec), Value(*(ValueImp **)b).toString(exec)); 282 ValueImp *va = *(ValueImp **)a; 283 ValueImp *vb = *(ValueImp **)b; 284 if (va->dispatchType() == UndefinedType) { 285 return vb->dispatchType() == UndefinedType ? 0 : 1; 286 } 287 if (vb->dispatchType() == UndefinedType) { 288 return -1; 289 } 290 return compare(va->dispatchToString(exec), vb->dispatchToString(exec)); 283 291 } 284 292 … … 313 321 { 314 322 CompareWithCompareFunctionArguments *args = compareWithCompareFunctionArguments; 315 323 324 ValueImp *va = *(ValueImp **)a; 325 ValueImp *vb = *(ValueImp **)b; 326 if (va->dispatchType() == UndefinedType) { 327 return vb->dispatchType() == UndefinedType ? 0 : 1; 328 } 329 if (vb->dispatchType() == UndefinedType) { 330 return -1; 331 } 332 316 333 args->arguments.clear(); 317 args->arguments.append(*(ValueImp **)a); 318 args->arguments.append(*(ValueImp **)b); 319 return args->compareFunction->call(args->exec, args->globalObject, args->arguments) 320 .toInt32(args->exec); 334 args->arguments.append(va); 335 args->arguments.append(vb); 336 double compareResult = args->compareFunction->call 337 (args->exec, args->globalObject, args->arguments).toNumber(args->exec); 338 return compareResult < 0 ? -1 : compareResult > 0 ? 1 : 0; 321 339 } 322 340 … … 626 644 { 627 645 Value jObj = thisObj.get(exec,j); 628 intcmp;646 double cmp; 629 647 if (jObj.type() == UndefinedType) { 630 cmp = 1; 648 cmp = 1; // don't check minObj because there's no need to differentiate == (0) from > (1) 631 649 } else if (minObj.type() == UndefinedType) { 632 650 cmp = -1; … … 635 653 l.append(jObj); 636 654 l.append(minObj); 637 cmp = sortFunction.call(exec, exec->interpreter()->globalObject(), l).to Int32(exec);655 cmp = sortFunction.call(exec, exec->interpreter()->globalObject(), l).toNumber(exec); 638 656 } else { 639 657 cmp = (jObj.toString(exec) < minObj.toString(exec)) ? -1 : 1;
Note:
See TracChangeset
for help on using the changeset viewer.