Skip to content

Commit e0d40b1

Browse files
authored
removed redundant object declarations (#7181)
1 parent b3a1134 commit e0d40b1

File tree

1 file changed

+21
-33
lines changed

1 file changed

+21
-33
lines changed

src/freadR.c

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -572,44 +572,32 @@ void dropFilledCols(int* dropArg, int ndelete)
572572

573573
void pushBuffer(ThreadLocalFreadParsingContext *ctx)
574574
{
575-
const void *buff8 = ctx->buff8;
576-
const void *buff4 = ctx->buff4;
577-
const void *buff1 = ctx->buff1;
578-
const char *anchor = ctx->anchor;
579-
const size_t nRows = ctx->nRows;
580-
const size_t DTi = ctx->DTi;
581-
const size_t rowSize8 = ctx->rowSize8;
582-
const size_t rowSize4 = ctx->rowSize4;
583-
const size_t rowSize1 = ctx->rowSize1;
584-
const int nStringCols = ctx->nStringCols;
585-
const int nNonStringCols = ctx->nNonStringCols;
586-
587575
// Do all the string columns first so as to minimize and concentrate the time inside the single critical.
588576
// While the string columns are happening other threads before me can be copying their non-string buffers to the
589577
// final DT and other threads after me can be filling their buffers too.
590578
// rowSize is passed in because it will be different (much smaller) on the reread covering any type exception columns
591579
// locals passed in on stack so openmp knows that no synchronization is required
592580

593581
// the byte position of this column in the first row of the row-major buffer
594-
if (nStringCols) {
582+
if (ctx->nStringCols) {
595583
#pragma omp critical
596584
{
597585
int off8 = 0;
598-
const int cnt8 = rowSize8 / 8;
599-
const lenOff *buff8_lenoffs = (const lenOff*)buff8;
600-
for (int j = 0, resj = -1, done = 0; done < nStringCols && j < ncol; j++) {
586+
const int cnt8 = ctx->rowSize8 / 8;
587+
const lenOff *buff8_lenoffs = (const lenOff*)ctx->buff8;
588+
for (int j = 0, resj = -1, done = 0; done < ctx->nStringCols && j < ncol; j++) {
601589
if (type[j] == CT_DROP) continue;
602590
resj++;
603591
if (type[j] == CT_STRING) {
604592
SEXP dest = VECTOR_ELT(DT, resj);
605593
const lenOff *source = buff8_lenoffs + off8;
606-
for (int i = 0; i < nRows; i++) {
594+
for (int i = 0; i < ctx->nRows; i++) {
607595
int strLen = source->len;
608596
if (strLen <= 0) {
609597
// stringLen == INT_MIN => NA, otherwise not a NAstring was checked inside fread_mean
610-
if (strLen < 0) SET_STRING_ELT(dest, DTi + i, NA_STRING); // else leave the "" in place that was initialized by allocVector()
598+
if (strLen < 0) SET_STRING_ELT(dest, ctx->DTi + i, NA_STRING); // else leave the "" in place that was initialized by allocVector()
611599
} else {
612-
const char *str = anchor + source->off;
600+
const char *str = ctx->anchor + source->off;
613601
int c = 0;
614602
while (c < strLen && str[c]) c++;
615603
if (c < strLen) {
@@ -621,7 +609,7 @@ void pushBuffer(ThreadLocalFreadParsingContext *ctx)
621609
}
622610
strLen = last - str;
623611
}
624-
SET_STRING_ELT(dest, DTi + i, mkCharLenCE(str, strLen, ienc));
612+
SET_STRING_ELT(dest, ctx->DTi + i, mkCharLenCE(str, strLen, ienc));
625613
}
626614
source += cnt8;
627615
}
@@ -634,41 +622,41 @@ void pushBuffer(ThreadLocalFreadParsingContext *ctx)
634622
}
635623

636624
int off1 = 0, off4 = 0, off8 = 0;
637-
for (int j = 0, resj = 0, done = 0; done < nNonStringCols && j < ncol; j++) {
625+
for (int j = 0, resj = 0, done = 0; done < ctx->nNonStringCols && j < ncol; j++) {
638626
if (type[j] == CT_DROP) continue;
639627

640628
if (type[j] != CT_STRING && type[j] > 0) {
641629
switch(size[j])
642630
{
643631
case 8: {
644-
double *dest = REAL(VECTOR_ELT(DT, resj)) + DTi;
645-
const char *src8 = (const char*)buff8 + off8;
646-
for (int i = 0; i < nRows; i++) {
632+
double *dest = REAL(VECTOR_ELT(DT, resj)) + ctx->DTi;
633+
const char *src8 = (const char*)ctx->buff8 + off8;
634+
for (int i = 0; i < ctx->nRows; i++) {
647635
*dest = *(double*)src8;
648-
src8 += rowSize8;
636+
src8 += ctx->rowSize8;
649637
dest++;
650638
}
651639
break;
652640
}
653641
case 4: {
654-
int *dest = INTEGER(VECTOR_ELT(DT, resj)) + DTi;
655-
const char *src4 = (const char*)buff4 + off4;
642+
int *dest = INTEGER(VECTOR_ELT(DT, resj)) + ctx->DTi;
643+
const char *src4 = (const char*)ctx->buff4 + off4;
656644
// debug line for #3369 ... if (DTi>2638000) printf("freadR.c:460: thisSize==4, resj=%d, %"PRIu64", %d, %d, j=%d, done=%d\n", resj, (uint64_t)DTi, off4, rowSize4, j, done);
657-
for (int i = 0; i < nRows; i++) {
645+
for (int i = 0; i < ctx->nRows; i++) {
658646
*dest = *(int*)src4;
659-
src4 += rowSize4;
647+
src4 += ctx->rowSize4;
660648
dest++;
661649
}
662650
break;
663651
}
664652
case 1: {
665653
if (type[j] > CT_BOOL8_Y) STOP(_("Field size is 1 but the field is of type %d\n"), type[j]);
666-
int *dest = LOGICAL(VECTOR_ELT(DT, resj)) + DTi;
667-
const char *src1 = (const char*)buff1 + off1;
668-
for (int i = 0; i < nRows; i++) {
654+
int *dest = LOGICAL(VECTOR_ELT(DT, resj)) + ctx->DTi;
655+
const char *src1 = (const char*)ctx->buff1 + off1;
656+
for (int i = 0; i < ctx->nRows; i++) {
669657
const int8_t v = *(int8_t*)src1;
670658
*dest = (v == INT8_MIN ? NA_INTEGER : v);
671-
src1 += rowSize1;
659+
src1 += ctx->rowSize1;
672660
dest++;
673661
}
674662
break;

0 commit comments

Comments
 (0)