Skip to content

Commit e142bae

Browse files
Merge pull request #16875 from Snuffleupagus/more-optional-chaining-4
Introduce more optional chaining in the code-base
2 parents 598421b + ec3d2be commit e142bae

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

src/core/worker_stream.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ class PDFWorkerStream {
4040
}
4141

4242
cancelAllRequests(reason) {
43-
if (this._fullRequestReader) {
44-
this._fullRequestReader.cancel(reason);
45-
}
43+
this._fullRequestReader?.cancel(reason);
44+
4645
for (const reader of this._rangeRequestReaders.slice(0)) {
4746
reader.cancel(reason);
4847
}

src/display/api.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -3153,11 +3153,7 @@ class PDFObjects {
31533153
* @returns {Object}
31543154
*/
31553155
#ensureObj(objId) {
3156-
const obj = this.#objs[objId];
3157-
if (obj) {
3158-
return obj;
3159-
}
3160-
return (this.#objs[objId] = {
3156+
return (this.#objs[objId] ||= {
31613157
capability: new PromiseCapability(),
31623158
data: null,
31633159
});

src/pdf.sandbox.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ class Sandbox {
107107
}
108108

109109
dumpMemoryUse() {
110-
if (this._module) {
111-
this._module.ccall("dumpMemoryUse", null, []);
112-
}
110+
this._module?.ccall("dumpMemoryUse", null, []);
113111
}
114112

115113
nukeSandbox() {

0 commit comments

Comments
 (0)