Unroll some async methods in stanza reader
This commit is contained in:
parent
567ac81d78
commit
87da6584c0
|
@ -63,14 +63,14 @@ public class StanzaReader {
|
||||||
if (buffer_pos >= buffer_fill) {
|
if (buffer_pos >= buffer_fill) {
|
||||||
yield update_buffer();
|
yield update_buffer();
|
||||||
}
|
}
|
||||||
char c = (char) buffer[buffer_pos++];
|
return (char) buffer[buffer_pos++];
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async char peek_single() throws XmlError {
|
private async char peek_single() throws XmlError {
|
||||||
var res = yield read_single();
|
if (buffer_pos >= buffer_fill) {
|
||||||
buffer_pos--;
|
yield update_buffer();
|
||||||
return res;
|
}
|
||||||
|
return (char) buffer[buffer_pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool is_ws(uint8 what) {
|
private bool is_ws(uint8 what) {
|
||||||
|
@ -82,37 +82,55 @@ public class StanzaReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void skip_until_non_ws() throws XmlError {
|
private async void skip_until_non_ws() throws XmlError {
|
||||||
while (is_ws(yield peek_single())) {
|
if (buffer_pos >= buffer_fill) {
|
||||||
skip_single();
|
yield update_buffer();
|
||||||
|
}
|
||||||
|
while (is_ws(buffer[buffer_pos])) {
|
||||||
|
buffer_pos++;
|
||||||
|
if (buffer_pos >= buffer_fill) {
|
||||||
|
yield update_buffer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async string read_until_ws() throws XmlError {
|
private async string read_until_ws() throws XmlError {
|
||||||
var res = new StringBuilder();
|
var res = new StringBuilder();
|
||||||
var what = yield peek_single();
|
if (buffer_pos >= buffer_fill) {
|
||||||
while (!is_ws(what)) {
|
yield update_buffer();
|
||||||
res.append_c(yield read_single());
|
}
|
||||||
what = yield peek_single();
|
while (!is_ws(buffer[buffer_pos])) {
|
||||||
|
res.append_c((char) buffer[buffer_pos++]);
|
||||||
|
if (buffer_pos >= buffer_fill) {
|
||||||
|
yield update_buffer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res.str;
|
return res.str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async string read_until_char_or_ws(char x, char y = 0) throws XmlError {
|
private async string read_until_char_or_ws(char x, char y = 0) throws XmlError {
|
||||||
var res = new StringBuilder();
|
var res = new StringBuilder();
|
||||||
var what = yield peek_single();
|
if (buffer_pos >= buffer_fill) {
|
||||||
while (what != x && what != y && !is_ws(what)) {
|
yield update_buffer();
|
||||||
res.append_c(yield read_single());
|
}
|
||||||
what = yield peek_single();
|
while (buffer[buffer_pos] != x && buffer[buffer_pos] != y && !is_ws(buffer[buffer_pos])) {
|
||||||
|
res.append_c((char) buffer[buffer_pos++]);
|
||||||
|
if (buffer_pos >= buffer_fill) {
|
||||||
|
yield update_buffer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res.str;
|
return res.str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async string read_until_char(char x) throws XmlError {
|
private async string read_until_char(char x) throws XmlError {
|
||||||
var res = new StringBuilder();
|
var res = new StringBuilder();
|
||||||
var what = yield peek_single();
|
if (buffer_pos >= buffer_fill) {
|
||||||
while (what != x) {
|
yield update_buffer();
|
||||||
res.append_c(yield read_single());
|
}
|
||||||
what = yield peek_single();
|
while (buffer[buffer_pos] != x) {
|
||||||
|
res.append_c((char) buffer[buffer_pos++]);
|
||||||
|
if (buffer_pos >= buffer_fill) {
|
||||||
|
yield update_buffer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res.str;
|
return res.str;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue