History

9gc: don't do too many reads

Sigrid Haflínudóttir committed 6 years ago

Commit f7df90b1 parent e0379841 file · +4 −2Browse files

Unified · Split

9gc.c+4−2
@@ -42,7 +42,7 @@ struct C9aux { · 41 unmodified lines
42};42};
43 43
44static const char *nick;44static const char *nick;
45static int printjoin, startlen;45static int printjoin, startlen, inflight;
46static uint64_t chatoff, skipuntil;46static uint64_t chatoff, skipuntil;
47static char start[256];47static char start[256];
48 48
@@ -176,6 +176,7 @@ ctxchatR(C9ctx *ctx, C9r *r) · 127 unmodified lines
176 break;176 break;
177 177
178 case Rread:178 case Rread:
179 inflight--;
179 if (chatoff == 0 && skipuntil > 0 && memcmp(start, r->read.data, MIN((int)r->read.size, startlen)) != 0) {180 if (chatoff == 0 && skipuntil > 0 && memcmp(start, r->read.data, MIN((int)r->read.size, startlen)) != 0) {
180 skipuntil = 0;181 skipuntil = 0;
181 startlen = 0;182 startlen = 0;
@@ -196,11 +197,12 @@ ctxchatR(C9ctx *ctx, C9r *r) · 14 unmodified lines
196 }197 }
197 /* gotta read fast */198 /* gotta read fast */
198 n = chatoff;199 n = chatoff;
199 for (i = 0; i < 4; i++) {200 for (i = 0; i < 4-inflight; i++) {
200 sz = n < skipuntil ? skipuntil-n : Msize;201 sz = n < skipuntil ? skipuntil-n : Msize;
201 c9read(ctx, &tag, Chatfid, n, sz);202 c9read(ctx, &tag, Chatfid, n, sz);
202 n += sz;203 n += sz;
203 }204 }
205 inflight = 4;
204 break;206 break;
205 207
206 case Rerror:208 case Rerror:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t