Inline the data lookup in the Dict.getArray
method
Similar to the `get`/`getAsync` methods, this should be a *tiny* bit more efficient which cannot hurt considering that `getArray` is now used a lot more than when initially added.
This commit is contained in:
parent
e394da5861
commit
70113131de
@ -118,17 +118,25 @@ class Dict {
|
||||
|
||||
// Same as get(), but dereferences all elements if the result is an Array.
|
||||
getArray(key1, key2, key3) {
|
||||
let value = this.get(key1, key2, key3);
|
||||
if (!Array.isArray(value) || !this.xref) {
|
||||
return value;
|
||||
let value = this._map[key1];
|
||||
if (value === undefined && key2 !== undefined) {
|
||||
value = this._map[key2];
|
||||
if (value === undefined && key3 !== undefined) {
|
||||
value = this._map[key3];
|
||||
}
|
||||
}
|
||||
if (value instanceof Ref && this.xref) {
|
||||
value = this.xref.fetch(value, this.suppressEncryption);
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value = value.slice(); // Ensure that we don't modify the Dict data.
|
||||
for (let i = 0, ii = value.length; i < ii; i++) {
|
||||
if (!(value[i] instanceof Ref)) {
|
||||
continue;
|
||||
}
|
||||
if (value[i] instanceof Ref && this.xref) {
|
||||
value[i] = this.xref.fetch(value[i], this.suppressEncryption);
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user