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.)
This commit is contained in:
Jonas Jenwald 2022-04-05 16:04:09 +02:00
parent 1dc4713a0b
commit a919959d83

View File

@ -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;