Verious small loop removals

This commit is contained in:
Willem Cazander 2025-01-20 03:22:20 +01:00
parent 72d8ff03a9
commit 7135a62ca3
4 changed files with 20 additions and 41 deletions

View file

@ -84,11 +84,7 @@ public class FourCornerUnicodeDisplay {
public void renderFromX06(List<FourCornerX06BaklavaPointSequence> chars, StringBuilder buf) { public void renderFromX06(List<FourCornerX06BaklavaPointSequence> chars, StringBuilder buf) {
List<Integer> charPoints = new ArrayList<>(chars.size()); List<Integer> charPoints = new ArrayList<>(chars.size());
for (FourCornerX06BaklavaPointSequence oven : chars) { chars.forEach(v -> charPoints.addAll(v.baklavaPointSequence()));
for (int v : oven.baklavaPointSequence()) {
charPoints.add(v);
}
}
renderFromInt18(charPoints, buf); renderFromInt18(charPoints, buf);
} }
@ -98,11 +94,7 @@ public class FourCornerUnicodeDisplay {
public void renderFromX08(List<FourCornerX08MuffinPointSequence> chars, StringBuilder buf) { public void renderFromX08(List<FourCornerX08MuffinPointSequence> chars, StringBuilder buf) {
List<Integer> charPoints = new ArrayList<>(chars.size()); List<Integer> charPoints = new ArrayList<>(chars.size());
for (FourCornerX08MuffinPointSequence oven : chars) { chars.forEach(v -> charPoints.addAll(v.muffinPointSequence()));
for (int v : oven.muffinPointSequence()) {
charPoints.add(v);
}
}
renderFromInt18(charPoints, buf); renderFromInt18(charPoints, buf);
} }
@ -112,11 +104,7 @@ public class FourCornerUnicodeDisplay {
public void renderFromX18(List<FourCornerX18CakePointSequence> chars, StringBuilder buf) { public void renderFromX18(List<FourCornerX18CakePointSequence> chars, StringBuilder buf) {
List<Integer> charPoints = new ArrayList<>(chars.size()); List<Integer> charPoints = new ArrayList<>(chars.size());
for (FourCornerX18CakePointSequence oven : chars) { chars.forEach(v -> charPoints.addAll(v.cakePointSequence()));
for (int v : oven.cakePointSequence()) {
charPoints.add(v);
}
}
renderFromInt18(charPoints, buf); renderFromInt18(charPoints, buf);
} }

View file

@ -60,11 +60,7 @@ public class FourCornerUnicodeImport {
public List<Integer> convertToInt18(String text) { public List<Integer> convertToInt18(String text) {
List<Integer> cakePoints = new ArrayList<>(text.length()); List<Integer> cakePoints = new ArrayList<>(text.length());
for (FourCornerX18CakePointSequence oven : convertToX18(text)) { convertToX18(text).forEach(v -> cakePoints.addAll(v.cakePointSequence()));
for (int v : oven.cakePointSequence()) {
cakePoints.add(v);
}
}
return cakePoints; return cakePoints;
} }

View file

@ -44,12 +44,12 @@ public interface FCDocSegmentWriter {
default void writeP7x(ApiDocContentWriter writer, FourCornerDotCake slice, Function<Integer, Integer> conv) throws IOException { default void writeP7x(ApiDocContentWriter writer, FourCornerDotCake slice, Function<Integer, Integer> conv) throws IOException {
String prefixHex = String.format("0x%06X", slice.getStart()); String prefixHex = String.format("0x%06X", slice.getStart());
try (ContentCloseable tableRow = writer.docTableRow()) { try (ContentCloseable tableRow = writer.docTableRow()) {
writer.printTagStart(Tag.td, ApiDocContentCss.colFirst); try (ContentCloseable td = writer.printTag(Tag.td, ApiDocContentCss.colFirst)) {
writer.printCharacters(prefixHex); writer.printCharacters(prefixHex);
writer.printTagEnd(Tag.td); }
writer.printTagStart(Tag.td, ApiDocContentCss.colOne); try (ContentCloseable td = writer.printTag(Tag.td, ApiDocContentCss.colOne)) {
writer.printCharacters(slice.nameSpec()); writer.printCharacters(slice.nameSpec());
writer.printTagEnd(Tag.td); }
for (int i = 0; i < 27; i++) { for (int i = 0; i < 27; i++) {
int codePoint = conv.apply(i); int codePoint = conv.apply(i);
if (i + 1 < 27) { if (i + 1 < 27) {
@ -111,13 +111,13 @@ public interface FCDocSegmentWriter {
for (int i = 0; i < headers.length; i++) { for (int i = 0; i < headers.length; i++) {
atts = new AttributesImpl(); atts = new AttributesImpl();
if (i == 0) { if (i == 0) {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colFirst.name()); atts.addAttribute("", "class", "", "", ApiDocContentCss.colFirst.name());
} else if (i == 1) { } else if (i == 1) {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colOne.name()); atts.addAttribute("", "class", "", "", ApiDocContentCss.colOne.name());
} else { } else {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name()); atts.addAttribute("", "class", "", "", ApiDocContentCss.colLast.name());
} }
atts.addAttribute ("", "scope", "", "", "col"); atts.addAttribute("", "scope", "", "", "col");
try (ContentCloseable th = writer.printTag(Tag.th, atts)) { try (ContentCloseable th = writer.printTag(Tag.th, atts)) {
writer.printCharacters(headers[i]); writer.printCharacters(headers[i]);
} }
@ -134,20 +134,20 @@ public interface FCDocSegmentWriter {
AttributesImpl atts; AttributesImpl atts;
if (colFirst) { if (colFirst) {
atts = new AttributesImpl(); atts = new AttributesImpl();
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colFirst.name()); atts.addAttribute("", "class", "", "", ApiDocContentCss.colFirst.name());
atts.addAttribute ("", "scope", "", "", "col"); atts.addAttribute("", "scope", "", "", "col");
writer.printTagStart(Tag.th, atts); writer.printTagStart(Tag.th, atts);
writer.printTagEnd(Tag.th); writer.printTagEnd(Tag.th);
} }
atts = new AttributesImpl(); atts = new AttributesImpl();
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colOne.name()); atts.addAttribute("", "class", "", "", ApiDocContentCss.colOne.name());
atts.addAttribute ("", "scope", "", "", "col"); atts.addAttribute("", "scope", "", "", "col");
writer.printTagStart(Tag.th, atts); writer.printTagStart(Tag.th, atts);
writer.printTagEnd(Tag.th); writer.printTagEnd(Tag.th);
for (int i = 0; i < num - 1; i++) { for (int i = 0; i < num - 1; i++) {
atts = new AttributesImpl(); atts = new AttributesImpl();
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name()); atts.addAttribute("", "class", "", "", ApiDocContentCss.colLast.name());
atts.addAttribute ("", "scope", "", "", "col"); atts.addAttribute("", "scope", "", "", "col");
writer.printTagStart(Tag.th, atts); writer.printTagStart(Tag.th, atts);
writer.printCharacters("0x"); writer.printCharacters("0x");
writer.printCharacters(Integer.toHexString(i).toUpperCase()); writer.printCharacters(Integer.toHexString(i).toUpperCase());

View file

@ -23,7 +23,6 @@
package org.x4o.fc18.cake2.fcdoc; package org.x4o.fc18.cake2.fcdoc;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -85,10 +84,6 @@ public class FCDocSegmentWriterCakeWord implements FCDocSegmentWriter {
writer.docTableEnd(); writer.docTableEnd();
} }
private void writeSequence(ApiDocContentWriter writer, String system, int[] sequence) throws IOException {
writeSequence(writer, system, Arrays.stream(sequence).mapToObj(v -> v).toList());
}
private void writeSequence(ApiDocContentWriter writer, String system, List<Integer> sequence) throws IOException { private void writeSequence(ApiDocContentWriter writer, String system, List<Integer> sequence) throws IOException {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
for (int i = 0; i < sequence.size(); i++) { for (int i = 0; i < sequence.size(); i++) {