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:
parent
1dc4713a0b
commit
a919959d83
@ -209,20 +209,16 @@ class Catalog {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const markInfo = Object.assign(Object.create(null), {
|
const markInfo = {
|
||||||
Marked: false,
|
Marked: false,
|
||||||
UserProperties: false,
|
UserProperties: false,
|
||||||
Suspects: false,
|
Suspects: false,
|
||||||
});
|
};
|
||||||
for (const key in markInfo) {
|
for (const key in markInfo) {
|
||||||
if (!obj.has(key)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const value = obj.get(key);
|
const value = obj.get(key);
|
||||||
if (typeof value !== "boolean") {
|
if (typeof value === "boolean") {
|
||||||
continue;
|
markInfo[key] = value;
|
||||||
}
|
}
|
||||||
markInfo[key] = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return markInfo;
|
return markInfo;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user