Skip to content

Commit fb00a95

Browse files
committed
removed typebump label and goto statements
removed the other goto statements, also general cleanup in the vicinity.
1 parent b002ad7 commit fb00a95

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/fread.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,24 +2481,27 @@ int freadMain(freadMainArgs _args) {
24812481
if (*tch==quote && quote) { quoted=true; tch++; }
24822482
} // else Field() handles NA inside it unlike other processors e.g. ,, is interpreted as "" or NA depending on option read inside Field()
24832483
fun[abs(thisType)](&fctx);
2484+
2485+
bool typeBump = false;
24842486
if (quoted) { // quoted was only set to true with '&& quote' above (=> quote!='\0' now)
2485-
if (*tch==quote) tch++;
2486-
else goto typebump;
2487+
if (*tch == quote) tch++;
2488+
else typeBump = true;
24872489
}
2488-
skip_white(&tch);
2489-
if (end_of_field(tch)) {
2490-
if (sep==' ' && *tch==' ') {
2491-
while (tch[1]==' ') tch++; // multiple space considered one sep so move to last
2492-
if (tch[1]=='\r' || tch[1]=='\n' || tch+1==eof) tch++;
2490+
2491+
if (!typeBump) {
2492+
skip_white(&tch);
2493+
if (end_of_field(tch)) {
2494+
if (sep == ' ' && *tch == ' ') {
2495+
while (tch[1] == ' ') tch++; // multiple space considered one sep so move to last
2496+
if (tch[1] == '\r' || tch[1] == '\n' || tch + 1 == eof) tch++;
2497+
}
2498+
break;
24932499
}
2494-
break;
24952500
}
2496-
24972501
// guess is insufficient out-of-sample, type is changed to negative sign and then bumped. Continue to
24982502
// check that the new type is sufficient for the rest of the column (and any other columns also in out-of-sample bump status) to be
24992503
// sure a single re-read will definitely work.
2500-
typebump:
2501-
while (++absType<CT_STRING && disabled_parsers[absType]) {};
2504+
while (++absType<CT_STRING && disabled_parsers[absType]);
25022505
thisType = -absType;
25032506
tch = fieldStart;
25042507
}
@@ -2646,13 +2649,12 @@ int freadMain(freadMainArgs _args) {
26462649
dropFill = (int *)malloc((size_t)ndropFill * sizeof(int));
26472650
if (!dropFill)
26482651
STOP(_("Failed to allocate %d bytes for '%s'."), (int)(ndropFill * sizeof(int)), "dropFill"); // # nocov
2649-
int i=0;
2650-
for (int j=max_col; j<ncol; ++j) {
2652+
for (int i=0,j=max_col;j<ncol;++i,++j) {
26512653
type[j] = CT_DROP;
26522654
size[j] = 0;
26532655
ndrop++;
26542656
nNonStringCols--;
2655-
dropFill[i++] = j;
2657+
dropFill[i] = j;
26562658
}
26572659
dropFilledCols(dropFill, ndropFill);
26582660
}
@@ -2696,8 +2698,10 @@ int freadMain(freadMainArgs _args) {
26962698

26972699
// if nTypeBump>0, not-bumped columns are about to be assigned parse type -CT_STRING for the reread, so we have to count
26982700
// parse types now (for log). We can't count final column types afterwards because many parse types map to the same column type.
2699-
for (int i=0; i<NUMTYPE; i++) typeCounts[i] = 0;
2700-
for (int i=0; i<ncol; i++) typeCounts[ abs(type[i]) ]++;
2701+
if (verbose) {
2702+
memset(typeCounts, 0, sizeof(typeCounts));
2703+
for (int i = 0; i < ncol; i++) typeCounts[abs(type[i])]++;
2704+
}
27012705

27022706
if (nTypeBump==0)break;
27032707

0 commit comments

Comments
 (0)