Skip to content

Commit 374f524

Browse files
committed
Remove unnecessary Map.prototype.entries() usage
A `Map` instance can be iterated directly with a `for...of` loop, hence using its `entries` method is not actually necessary.
1 parent 74ab1a9 commit 374f524

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/core/default_appearance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class FakeUnicodeFont {
294294
descendantFont.set("DW", 1000);
295295

296296
const widths = [];
297-
const chars = [...this.widths.entries()].sort();
297+
const chars = [...this.widths].sort();
298298
let currentChar = null;
299299
let currentWidths = null;
300300
for (const [char, width] of chars) {

src/core/xfa/fonts.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ class FontFinder {
105105
name = name.toLowerCase();
106106

107107
const maybe = [];
108-
for (const [family, pdfFont] of this.fonts.entries()) {
108+
for (const [family, pdfFont] of this.fonts) {
109109
if (family.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
110110
maybe.push(pdfFont);
111111
}
112112
}
113113

114114
if (maybe.length === 0) {
115-
for (const [, pdfFont] of this.fonts.entries()) {
115+
for (const pdfFont of this.fonts.values()) {
116116
if (
117117
pdfFont.regular.name
118118
?.replaceAll(pattern, "")
@@ -126,7 +126,7 @@ class FontFinder {
126126

127127
if (maybe.length === 0) {
128128
name = name.replaceAll(/psmt|mt/gi, "");
129-
for (const [family, pdfFont] of this.fonts.entries()) {
129+
for (const [family, pdfFont] of this.fonts) {
130130
if (family.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
131131
maybe.push(pdfFont);
132132
}

src/core/xfa/xfa_object.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ class XmlObject extends XFAObject {
841841
const utf8TagName = utf8StringToString(tagName);
842842
const prefix = this[$namespaceId] === NS_DATASETS ? "xfa:" : "";
843843
buf.push(`<${prefix}${utf8TagName}`);
844-
for (const [name, value] of this[_attributes].entries()) {
844+
for (const [name, value] of this[_attributes]) {
845845
const utf8Name = utf8StringToString(name);
846846
buf.push(` ${utf8Name}="${encodeToXmlString(value[$content])}"`);
847847
}

src/scripting_api/doc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ class Doc extends PDFObject {
951951
cName = parts[0];
952952
}
953953

954-
for (const [name, field] of this._fields.entries()) {
954+
for (const [name, field] of this._fields) {
955955
if (name.endsWith(cName)) {
956956
if (!isNaN(childIndex)) {
957957
const children = this._getChildren(name);
@@ -985,7 +985,7 @@ class Doc extends PDFObject {
985985
const len = fieldName.length;
986986
const children = [];
987987
const pattern = /^\.[^.]+$/;
988-
for (const [name, field] of this._fields.entries()) {
988+
for (const [name, field] of this._fields) {
989989
if (name.startsWith(fieldName)) {
990990
const finalPart = name.slice(len);
991991
if (pattern.test(finalPart)) {
@@ -1000,7 +1000,7 @@ class Doc extends PDFObject {
10001000
// Get all the descendants which have a value.
10011001
const children = [];
10021002
const len = fieldName.length;
1003-
for (const [name, field] of this._fields.entries()) {
1003+
for (const [name, field] of this._fields) {
10041004
if (name.startsWith(fieldName)) {
10051005
const finalPart = name.slice(len);
10061006
if (

0 commit comments

Comments
 (0)