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

View file

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

View file

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

View file

@ -23,7 +23,6 @@
package org.x4o.fc18.cake2.fcdoc;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
@ -85,10 +84,6 @@ public class FCDocSegmentWriterCakeWord implements FCDocSegmentWriter {
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 {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < sequence.size(); i++) {