Skip to content

Commit b44bf3b

Browse files
committed
Replace Collections.nCopies() with simple loop.
1 parent 8c23281 commit b44bf3b

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

io/src/main/java/com/itextpdf/io/font/otf/Glyph.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,7 @@ public boolean equals(Object obj) {
230230
if (this == obj) {
231231
return true;
232232
}
233-
if (obj == null) {
234-
return false;
235-
}
236-
if (getClass() != obj.getClass()) {
233+
if (!(obj instanceof Glyph)) {
237234
return false;
238235
}
239236
Glyph other = (Glyph) obj;

io/src/main/java/com/itextpdf/io/font/otf/GlyphLine.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public GlyphLine(List<Glyph> glyphs, int start, int end) {
3030
this.end = end;
3131
}
3232

33-
public GlyphLine(List<Glyph> glyphs, List<ActualText> actualText, int start, int end) {
33+
protected GlyphLine(List<Glyph> glyphs, List<ActualText> actualText, int start, int end) {
3434
this(glyphs, start, end);
3535
this.actualText = actualText;
3636
}
@@ -217,8 +217,8 @@ public GlyphLine filter(GlyphLineFilter filter) {
217217
public void setActualText(int left, int right, String text) {
218218
if (this.actualText == null) {
219219
this.actualText = new ArrayList<>(glyphs.size());
220-
List<ActualText> actualText = Collections.nCopies(glyphs.size(), null);
221-
this.actualText.addAll(actualText);
220+
for (int i = 0; i < glyphs.size(); i++)
221+
this.actualText.add(null);
222222
}
223223
ActualText actualText = new ActualText(text);
224224
for (int i = left; i < right; i++) {
@@ -241,8 +241,9 @@ private void removeGlyph(int index) {
241241
private void addAllGlyphs(int index, List<Glyph> additionalGlyphs) {
242242
glyphs.addAll(index, additionalGlyphs);
243243
if (actualText != null) {
244-
List<ActualText> actualTexts = Collections.nCopies(additionalGlyphs.size(), null);
245-
actualText.addAll(index, actualTexts);
244+
for (int i = 0; i < additionalGlyphs.size(); i++) {
245+
this.actualText.add(index, null);
246+
}
246247
}
247248
}
248249

0 commit comments

Comments
 (0)