Skip to content

Commit 92325aa

Browse files
committed
updated fast-io.hpp
1 parent eb260a0 commit 92325aa

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/alfred/config/fast-io.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
class FastIO {
88
private:
9-
char *buf, *p1, *p2, *obuf, *op;
109
static const int chunk = 1 << 18;
10+
char *ibuf, *p1, *p2, *obuf, *op, *oe;
1111

1212
inline void flush_output(int len = chunk) {
1313
fwrite(obuf, 1, len, stdout), op = obuf;
@@ -16,22 +16,22 @@ class FastIO {
1616
public:
1717
inline char nc(void) {
1818
if (p1 == p2) {
19-
p2 = (p1 = buf) + fread(buf, 1, chunk, stdin);
19+
p2 = (p1 = ibuf) + fread(ibuf, 1, chunk, stdin);
2020
if (p1 == p2) return EOF;
2121
}
2222
return *p1++;
2323
}
2424
inline void pc(char c) {
25-
if (op == obuf + chunk) flush_output();
25+
if (op == oe) flush_output();
2626
*op++ = c;
2727
}
2828
FastIO(void) {
29-
p1 = p2 = buf = (char *)(malloc(chunk));
30-
op = obuf = (char *)(malloc(chunk));
29+
p1 = p2 = ibuf = (char *)(malloc(chunk));
30+
op = obuf = (char *)(malloc(chunk)), oe = obuf + chunk;
3131
}
3232
~FastIO(void) {
3333
flush_output(op - obuf);
34-
free(buf), free(obuf);
34+
free(ibuf), free(obuf);
3535
}
3636
inline void flush(void) {
3737
flush_output(op - obuf);

0 commit comments

Comments
 (0)