mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
Fixed connect to not call strlen() over and over again in a loop
This commit is contained in:
parent
864847d1cc
commit
0403313bdb
1 changed files with 11 additions and 7 deletions
|
@ -856,6 +856,7 @@ bool TDBCSV::SkipHeader(PGLOBAL g)
|
|||
int hlen = 0;
|
||||
bool q = Qot && Quoted > 0;
|
||||
PCOLDEF cdp;
|
||||
char *pos, *end;
|
||||
|
||||
// Estimate the length of the header list
|
||||
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
|
||||
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
|
||||
for (i = 1; i <= n; i++)
|
||||
for (cdp = To_Def->GetCols(); cdp; cdp = cdp->GetNext())
|
||||
if (cdp->GetOffset() == i) {
|
||||
if (q)
|
||||
To_Line[strlen(To_Line)] = Qot;
|
||||
if (q && pos < end)
|
||||
*pos++= Qot;
|
||||
|
||||
safe_strcat(To_Line, Lrecl, cdp->GetName());
|
||||
pos= strnmov(pos, cdp->GetName(), (size_t) (end-pos));
|
||||
|
||||
if (q)
|
||||
To_Line[strlen(To_Line)] = Qot;
|
||||
if (q && pos < end)
|
||||
*pos++= Qot;
|
||||
|
||||
if (i < n)
|
||||
To_Line[strlen(To_Line)] = Sep;
|
||||
if (i < n && pos < end)
|
||||
*pos++= Sep;
|
||||
|
||||
} // endif Offset
|
||||
*pos= 0;
|
||||
|
||||
rc = (Txfp->WriteBuffer(g) == RC_FX);
|
||||
} // endif !FileLength
|
||||
|
|
Loading…
Reference in a new issue