From 6c6ced24427b08d701ea944bffa7a99e5a81e05a Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Wed, 24 Dec 2014 16:26:43 +0300 Subject: [PATCH] Minor in JS lib: avoid to use undefined literal which may be over overlapped. --- js/js.translator/testData/kotlin_lib.js | 18 +++++++++--------- js/js.translator/testData/kotlin_lib_ecma5.js | 2 +- js/js.translator/testData/maps.js | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/js/js.translator/testData/kotlin_lib.js b/js/js.translator/testData/kotlin_lib.js index 0d73f23f374..c244dee9deb 100644 --- a/js/js.translator/testData/kotlin_lib.js +++ b/js/js.translator/testData/kotlin_lib.js @@ -41,7 +41,7 @@ return Kotlin.arrayEquals(obj1, obj2); } - if (typeof obj1 == "object" && obj1.equals_za3rmp$ !== undefined) { + if (typeof obj1 == "object" && typeof obj1.equals_za3rmp$ === "function") { return obj1.equals_za3rmp$(obj2); } @@ -170,7 +170,7 @@ return Kotlin.createClassNow(base, /** @constructs */ function (message) { - this.message = (message !== undefined) ? message : null; + this.message = (message !== void 0) ? message : null; } ); } @@ -191,7 +191,7 @@ function throwAbstractFunctionInvocationError(funName) { return function () { var message; - if (funName !== undefined) { + if (funName !== void 0) { message = "Function " + funName + " is abstract"; } else { @@ -283,8 +283,8 @@ Kotlin.Enum = Kotlin.createClassNow(null, function () { - this.name$ = undefined; - this.ordinal$ = undefined; + this.name$ = void 0; + this.ordinal$ = void 0; }, { name: function () { return this.name$; @@ -848,8 +848,8 @@ }; Kotlin.collectionsSort = function (mutableList, comparator) { - var boundComparator = undefined; - if (comparator !== undefined) { + var boundComparator = void 0; + if (comparator !== void 0) { boundComparator = comparator.compare.bind(comparator); } @@ -887,9 +887,9 @@ this.string = ""; }, { append: function (obj, from, to) { - if (from == undefined && to == undefined) { + if (from == void 0 && to == void 0) { this.string = this.string + obj.toString(); - } else if (to == undefined) { + } else if (to == void 0) { this.string = this.string + obj.toString().substring(from); } else { this.string = this.string + obj.toString().substring(from, to); diff --git a/js/js.translator/testData/kotlin_lib_ecma5.js b/js/js.translator/testData/kotlin_lib_ecma5.js index 019f9ff3925..00a40de6254 100644 --- a/js/js.translator/testData/kotlin_lib_ecma5.js +++ b/js/js.translator/testData/kotlin_lib_ecma5.js @@ -383,7 +383,7 @@ var Kotlin = {}; var obj = {}; obj.name = name; obj.get_za3rmp$ = getFun; - if (setFun !== undefined) { + if (typeof setFun === "function") { obj.set_wn2jw4$ = setFun; } return obj; diff --git a/js/js.translator/testData/maps.js b/js/js.translator/testData/maps.js index f286d985ed3..a90b8777a78 100644 --- a/js/js.translator/testData/maps.js +++ b/js/js.translator/testData/maps.js @@ -47,7 +47,7 @@ } function hashSetEquals(o) { - if (o === null || o === undefined || this.size() !== o.size()) return false; + if (o == null || this.size() !== o.size()) return false; return this.containsAll_4fm7v2$(o); } @@ -511,7 +511,7 @@ }, containsKey_za3rmp$: function (key) { // TODO: should process "__proto__" separately? - return this.map[key] !== undefined; + return this.map[key] !== void 0; }, containsValue_za3rmp$: function (value) { var map = this.map; @@ -529,15 +529,15 @@ }, put_wn2jw4$: function (key, value) { var prevValue = this.map[key]; - this.map[key] = value === undefined ? null : value; - if (prevValue === undefined) { + this.map[key] = value === void 0 ? null : value; + if (prevValue === void 0) { this.$size++; } return prevValue; }, remove_za3rmp$: function (key) { var prevValue = this.map[key]; - if (prevValue !== undefined) { + if (prevValue !== void 0) { delete this.map[key]; this.$size--; }