Changeset View
Changeset View
Standalone View
Standalone View
sys/gdb/gdb_packet.c
Show First 20 Lines • Show All 309 Lines • ▼ Show 20 Lines | while (p < gdb_txp) { | ||||
cksum += 97+29; | cksum += 97+29; | ||||
runlen -= 97; | runlen -= 97; | ||||
if (runlen > 0) { | if (runlen > 0) { | ||||
gdb_cur->gdb_putc(c); | gdb_cur->gdb_putc(c); | ||||
cksum += c; | cksum += c; | ||||
runlen--; | runlen--; | ||||
} | } | ||||
} | } | ||||
if (runlen == 1) { | /* Don't emit '$', '#', '+', '-' or a run length below 3. */ | ||||
while (runlen == 1 || runlen == 2 || | |||||
emaste: It took me a moment to understand the intent here -- do you think this might be even more clear? | |||||
Done Inline ActionsYes, I was thinking of replacing it with while but it would add at least one extra iteration of checks for every symbol, wouldn't it? I mean, if that cost is fine, I can do it. mgorny_gentoo.org: Yes, I was thinking of replacing it with while but it would add at least one extra iteration of… | |||||
Done Inline ActionsI don't think so, the only extra work is the addition of a few extraneous tests (e.g. if runlen starts at 7 we'd have a few comparisons that happen twice instead of once). emaste: I don't think so, the only extra work is the addition of a few extraneous tests (e.g. if runlen… | |||||
runlen + 29 == '$' || runlen + 29 == '#' || | |||||
runlen + 29 == '+' || runlen + 29 == '-') { | |||||
gdb_cur->gdb_putc(c); | gdb_cur->gdb_putc(c); | ||||
cksum += c; | cksum += c; | ||||
runlen--; | runlen--; | ||||
} | } | ||||
if (runlen == 0) | if (runlen == 0) | ||||
continue; | continue; | ||||
/* Don't emit '$', '#', '+' or '-'. */ | |||||
if (runlen == 7) { | |||||
gdb_cur->gdb_putc(c); | |||||
cksum += c; | |||||
runlen--; | |||||
} | |||||
if (runlen == 6 || runlen == 14 || runlen == 16) { | |||||
gdb_cur->gdb_putc(c); | |||||
cksum += c; | |||||
runlen--; | |||||
} | |||||
gdb_cur->gdb_putc('*'); | gdb_cur->gdb_putc('*'); | ||||
cksum += '*'; | cksum += '*'; | ||||
gdb_cur->gdb_putc(runlen+29); | gdb_cur->gdb_putc(runlen+29); | ||||
cksum += runlen+29; | cksum += runlen+29; | ||||
} | } | ||||
gdb_cur->gdb_putc('#'); | gdb_cur->gdb_putc('#'); | ||||
c = cksum >> 4; | c = cksum >> 4; | ||||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |
It took me a moment to understand the intent here -- do you think this might be even more clear?
or even runlen == 1 || runlen = 2 || runlen + 29 == '$' || runlen + 29 == '#' || ...?