| Index: src/runtime.js
|
| ===================================================================
|
| --- src/runtime.js (revision 4001)
|
| +++ src/runtime.js (working copy)
|
| @@ -52,43 +52,28 @@
|
|
|
| // ECMA-262, section 11.9.1, page 55.
|
| function EQUALS(y) {
|
| - if (IS_STRING(this) && IS_STRING(y)) return %StringEquals(this, y);
|
| + var r = %FastEquals(this, y);
|
| + if (r <= 1) return r;
|
| var x = this;
|
|
|
| // NOTE: We use iteration instead of recursion, because it is
|
| // difficult to call EQUALS with the correct setting of 'this' in
|
| // an efficient way.
|
| while (true) {
|
| - if (IS_NUMBER(x)) {
|
| - if (y == null) return 1; // not equal
|
| - return %NumberEquals(x, %ToNumber(y));
|
| - } else if (IS_STRING(x)) {
|
| - if (IS_STRING(y)) return %StringEquals(x, y);
|
| - if (IS_NUMBER(y)) return %NumberEquals(%ToNumber(x), y);
|
| - if (IS_BOOLEAN(y)) return %NumberEquals(%ToNumber(x), %ToNumber(y));
|
| - if (y == null) return 1; // not equal
|
| + if (r == EQUALS_SECOND_ARG_TO_DEFAULT_VALUE) {
|
| + x = %ToNumber(x);
|
| + y = %ToNumber(%DefaultNumber(y));
|
| + return %NumberEquals(x, y);
|
| + } else if (r == EQUALS_SECOND_ARG_TO_PRIMITIVE) {
|
| y = %ToPrimitive(y, NO_HINT);
|
| - } else if (IS_BOOLEAN(x)) {
|
| - if (IS_BOOLEAN(y)) {
|
| - return %_ObjectEquals(x, y) ? 0 : 1;
|
| - }
|
| - if (y == null) return 1; // not equal
|
| - return %NumberEquals(%ToNumber(x), %ToNumber(y));
|
| - } else if (x == null) {
|
| - // NOTE: This checks for both null and undefined.
|
| - return (y == null) ? 0 : 1;
|
| - } else {
|
| - // x is not a number, boolean, null or undefined.
|
| - if (y == null) return 1; // not equal
|
| - if (IS_OBJECT(y)) {
|
| - return %_ObjectEquals(x, y) ? 0 : 1;
|
| - }
|
| - if (IS_FUNCTION(y)) {
|
| - return %_ObjectEquals(x, y) ? 0 : 1;
|
| - }
|
| -
|
| + // retry
|
| + } else if (r == EQUALS_FIRST_ARG_TO_PRIMITIVE) {
|
| x = %ToPrimitive(x, NO_HINT);
|
| + // retry
|
| }
|
| +
|
| + var r = %FastEquals(x, y);
|
| + if (r <= 1) return r;
|
| }
|
| }
|
|
|
|
|