Index: src/runtime.js |
=================================================================== |
--- src/runtime.js (revision 478) |
+++ src/runtime.js (working copy) |
@@ -94,24 +94,17 @@ |
if (IS_NUMBER(this)) { |
if (!IS_NUMBER(x)) return 1; // not equal |
return %NumberEquals(this, x); |
- } |
- |
- if (IS_STRING(this)) { |
+ } else if (IS_STRING(this)) { |
bak
2008/10/10 06:23:44
What is up with excessive use of else parts.
retur
|
if (!IS_STRING(x)) return 1; // not equal |
return %StringEquals(this, x); |
- } |
- |
- if (IS_BOOLEAN(this)) { |
- if (!IS_BOOLEAN(x)) return 1; // not equal |
- if (this) return x ? 0 : 1; |
- else return x ? 1 : 0; |
- } |
- |
- if (IS_UNDEFINED(this)) { // both undefined and undetectable |
+ } else if (IS_UNDEFINED(this)) { |
+ // Both undefined and undetectable. |
return IS_UNDEFINED(x) ? 0 : 1; |
+ } else { |
+ // Objects, null, booleans and functions are all that's left. |
+ // They can all be compared with a simple identity check. |
+ return %_ObjectEquals(this, x) ? 0 : 1; |
} |
- |
- return %_ObjectEquals(this, x) ? 0 : 1; |
} |