From a919959d8388602d0789a1b56e093a67678cd1fd Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 5 Apr 2022 16:04:09 +0200 Subject: [PATCH] Slightly simplify the `Catalog._readMarkInfo` method We don't need to first check if the Dictionary contains the key, since trying to get a non-existent key simply returns `undefined` and we're already ensuring that the value is a boolean. Furthermore, we shouldn't need to worry about the `Object.prototype` containing enumerable properties since the checks (in `src/core/worker.js`) done for `Array.prototype` *indirectly* also cover `Object`s. (Keep in mind that an `Array` is just a special kind of `Object` in JavaScript.) --- src/core/catalog.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/core/catalog.js b/src/core/catalog.js index 13f54f75d..dcc509c91 100644 --- a/src/core/catalog.js +++ b/src/core/catalog.js @@ -209,20 +209,16 @@ class Catalog { return null; } - const markInfo = Object.assign(Object.create(null), { + const markInfo = { Marked: false, UserProperties: false, Suspects: false, - }); + }; for (const key in markInfo) { - if (!obj.has(key)) { - continue; - } const value = obj.get(key); - if (typeof value !== "boolean") { - continue; + if (typeof value === "boolean") { + markInfo[key] = value; } - markInfo[key] = value; } return markInfo;