[go: up one dir, main page]

Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
transfered Class[] to ArrayList<Class>
Browse files Browse the repository at this point in the history
  • Loading branch information
velnias75 committed Aug 9, 2021
1 parent 83b2edc commit 434b531
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/main/java/de/rangun/luegenpresse/spew/Spew.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;

Expand All @@ -38,7 +39,6 @@ public final class Spew {

private final static Random rnd = new Random();

private final static int MAXCLASS = 300;
private final static int MAXLINE = 256;

private final static byte VBAR = '|';
Expand All @@ -56,8 +56,7 @@ public final class Spew {

private BufferedReader InFile;

private Class[] Class;
private int Classes;
private ArrayList<Class> Class = new ArrayList<>();
private byte[] InLine = new byte[MAXLINE];

public Spew(final File in) throws IOException, SpewException {
Expand Down Expand Up @@ -97,26 +96,17 @@ private void readtext() throws IOException, SpewException {
Class cp;
defn dp;
defn update;
int ci = 0;

Class = new Class[MAXCLASS];
cp = new Class();
Class.add(cp);

for (int i = 0; i < Class.length; ++i)
Class[i] = new Class();

Classes = 0;

cp = Class[ci];
readline();

if (InLine[0] != '%')
throw new SpewException("Class definition expected at: ", InLine);

while (InLine[1] != '%') {

if (Classes == MAXCLASS)
throw new SpewException("Too many classes -- max = ", MAXCLASS);

setup(cp);
readline();

Expand All @@ -143,13 +133,16 @@ private void readtext() throws IOException, SpewException {

} while (nextLine());

++Classes;
cp = Class[++ci];
cp = new Class();
Class.add(cp);

update = null;
}

Arrays.sort(Class, 0, Classes);
Class.remove(Class.size() - 1);
Class.trimToSize();

Collections.sort(Class);
}

private boolean nextLine() throws IOException {
Expand Down Expand Up @@ -209,8 +202,10 @@ private void setup(Class cp) throws SpewException {

cp.weight = 0;
cp.name = save(temp);
cp.name.trimToSize();
cp.list = null;
cp.tags = NullTags;
cp.tags.trimToSize();

--p;

Expand Down Expand Up @@ -241,6 +236,8 @@ private void setup(Class cp) throws SpewException {
temp.set(p2, (byte) '\0');

cp.tags = save(temp);
cp.tags.trimToSize();

break;
default:
baddec();
Expand Down Expand Up @@ -331,6 +328,7 @@ private defn process() throws SpewException, IOException {

stuff.add((byte) '\0');
dp.string = save(stuff);
dp.string.trimToSize();

return dp;

Expand Down Expand Up @@ -468,15 +466,15 @@ private Class lookup(final List<Byte> str) {
int comp;
int tryy;
int first = 0;
int last = Classes - 1;
int last = Class.size() - 1;

while (first <= last) {

tryy = (first + last) >> 1;
comp = namecomp(str, Class[tryy].name);
comp = namecomp(str, Class.get(tryy).name);

if (comp == 0)
return Class[tryy];
return Class.get(tryy);

if (comp > 0) {
first = tryy + 1;
Expand Down

0 comments on commit 434b531

Please sign in to comment.