Fixed connect to not call strlen() over and over again in a loop
This commit is contained in:
parent
864847d1cc
commit
0403313bdb
@ -856,6 +856,7 @@ bool TDBCSV::SkipHeader(PGLOBAL g)
|
|||||||
int hlen = 0;
|
int hlen = 0;
|
||||||
bool q = Qot && Quoted > 0;
|
bool q = Qot && Quoted > 0;
|
||||||
PCOLDEF cdp;
|
PCOLDEF cdp;
|
||||||
|
char *pos, *end;
|
||||||
|
|
||||||
// Estimate the length of the header list
|
// Estimate the length of the header list
|
||||||
for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext()) {
|
for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext()) {
|
||||||
@ -871,23 +872,26 @@ bool TDBCSV::SkipHeader(PGLOBAL g)
|
|||||||
|
|
||||||
// File is empty, write a header record
|
// File is empty, write a header record
|
||||||
memset(To_Line, 0, Lrecl);
|
memset(To_Line, 0, Lrecl);
|
||||||
|
pos= To_Line;
|
||||||
|
end= To_Line + Lrecl-1;
|
||||||
|
|
||||||
// The column order in the file is given by the offset value
|
// The column order in the file is given by the offset value
|
||||||
for (i = 1; i <= n; i++)
|
for (i = 1; i <= n; i++)
|
||||||
for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext())
|
for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext())
|
||||||
if (cdp->GetOffset() == i) {
|
if (cdp->GetOffset() == i) {
|
||||||
if (q)
|
if (q && pos < end)
|
||||||
To_Line[strlen(To_Line)] = Qot;
|
*pos++= Qot;
|
||||||
|
|
||||||
safe_strcat(To_Line, Lrecl, cdp->GetName());
|
pos= strnmov(pos, cdp->GetName(), (size_t) (end-pos));
|
||||||
|
|
||||||
if (q)
|
if (q && pos < end)
|
||||||
To_Line[strlen(To_Line)] = Qot;
|
*pos++= Qot;
|
||||||
|
|
||||||
if (i < n)
|
if (i < n && pos < end)
|
||||||
To_Line[strlen(To_Line)] = Sep;
|
*pos++= Sep;
|
||||||
|
|
||||||
} // endif Offset
|
} // endif Offset
|
||||||
|
*pos= 0;
|
||||||
|
|
||||||
rc = (Txfp->WriteBuffer(g) == RC_FX);
|
rc = (Txfp->WriteBuffer(g) == RC_FX);
|
||||||
} // endif !FileLength
|
} // endif !FileLength
|
||||||
|
Loading…
x
Reference in New Issue
Block a user