1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Add a getRawValues method, to Dict instances, to provide an easier way of getting all *raw* values

When the old `Dict.getAll()` method was removed, it was replaced with a `Dict.getKeys()` call and `Dict.get(...)` calls (in a loop).
While this pattern obviously makes a lot of sense in many cases, there's some instances where we actually want the *raw* `Dict` values (i.e. `Ref`s where applicable). In those cases, `Dict.getRaw(...)` calls are instead used within the loop. However, by introducing a new `Dict.getRawValues()` method we can reduce the number of (strictly unnecessary) function calls by simply getting the *raw* `Dict` values directly.
This commit is contained in:
Jonas Jenwald 2020-07-17 12:57:34 +02:00
parent 6381b5b08f
commit ea8e432c45
4 changed files with 39 additions and 12 deletions

View file

@ -144,6 +144,11 @@ var Dict = (function DictClosure() {
return Object.keys(this._map);
},
// no dereferencing
getRawValues: function Dict_getRawValues() {
return Object.values(this._map);
},
set: function Dict_set(key, value) {
if (
(typeof PDFJSDev === "undefined" ||