Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jul 30, 2024
1 parent a1e69cd commit 7dc7918
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package xyz.wagyourtail.jvmdg.util;
package xyz.wagyourtail.jvmdg.j11.impl;


import java.util.Set;

public class CharReader {
private final String buffer;
private int pos = 0;
private int pos;

public CharReader(String buf, int pos) {
this.buffer = buf.replace("\r\n", "\n");
this.pos = pos;
}

public CharReader copy() {
return new CharReader(buffer, pos);
}

public boolean exhausted() {
return pos >= buffer.length();
}
Expand All @@ -30,27 +26,6 @@ public int take() {
return buffer.charAt(pos++);
}

public String takeRemaining() {
return takeUntil(-1);
}

public String takeLine() {
return takeUntil('\n');
}

public String takeUntil(int c) {
StringBuilder sb = new StringBuilder();
while (pos < buffer.length()) {
char ch = buffer.charAt(pos);
if (ch == c) {
break;
}
sb.append(ch);
pos++;
}
return sb.toString();
}

public String takeUntil(Set<Integer> c) {
StringBuilder sb = new StringBuilder();
while (pos < buffer.length()) {
Expand All @@ -64,17 +39,13 @@ public String takeUntil(Set<Integer> c) {
return sb.toString();
}

public String takeWhitespace() {
StringBuilder sb = new StringBuilder();
public void takeWhitespace() {
while (pos < buffer.length()) {
char ch = buffer.charAt(pos);
if (!Character.isWhitespace(ch)) {
if (!Character.isWhitespace(buffer.charAt(pos))) {
break;
}
pos++;
sb.append(ch);
}
return sb.toString();
}

public String takeString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

import xyz.wagyourtail.jvmdg.exc.MissingStubError;
import xyz.wagyourtail.jvmdg.j11.stub.java_base.J_L_String;
import xyz.wagyourtail.jvmdg.util.CharReader;
import xyz.wagyourtail.jvmdg.j11.impl.CharReader;
import xyz.wagyourtail.jvmdg.util.Consumer;
import xyz.wagyourtail.jvmdg.util.Function;
import xyz.wagyourtail.jvmdg.version.Adapter;

import javax.net.ssl.SSLSession;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
Expand Down

0 comments on commit 7dc7918

Please sign in to comment.