avoid excessive calling of std::ios::widen - refs #3101
This commit is contained in:
parent
da054c84e6
commit
336170c13c
2 changed files with 8 additions and 5 deletions
|
@ -42,9 +42,10 @@ public:
|
|||
std::string csv_line;
|
||||
std::stringstream s;
|
||||
s << line_data_;
|
||||
auto newline_widened = s.widen(newline);
|
||||
for (unsigned i=0;i<iterations_;++i)
|
||||
{
|
||||
std::getline(s,csv_line,s.widen(newline));
|
||||
std::getline(s,csv_line,newline_widened);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -90,9 +91,10 @@ public:
|
|||
std::string csv_line;
|
||||
std::stringstream s;
|
||||
s << line_data_;
|
||||
auto newline_widened = s.widen(newline);
|
||||
for (unsigned i=0;i<iterations_;++i)
|
||||
{
|
||||
csv_utils::getline_csv(s,csv_line,s.widen(newline));
|
||||
csv_utils::getline_csv(s,csv_line,newline_widened);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -170,11 +170,12 @@ void csv_datasource::parse_csv(T & stream,
|
|||
char newline;
|
||||
bool has_newline;
|
||||
std::tie(newline, has_newline) = detail::autodect_newline(stream, file_length);
|
||||
char widened_newline = stream.widen(newline);
|
||||
// set back to start
|
||||
stream.seekg(0, std::ios::beg);
|
||||
// get first line
|
||||
std::string csv_line;
|
||||
csv_utils::getline_csv(stream,csv_line,stream.widen(newline));
|
||||
csv_utils::getline_csv(stream,csv_line,widened_newline);
|
||||
// if user has not passed a separator manually
|
||||
// then attempt to detect by reading first line
|
||||
|
||||
|
@ -208,7 +209,7 @@ void csv_datasource::parse_csv(T & stream,
|
|||
}
|
||||
else // parse first line as headers
|
||||
{
|
||||
while (csv_utils::getline_csv(stream,csv_line,stream.widen(newline)))
|
||||
while (csv_utils::getline_csv(stream,csv_line,widened_newline))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -293,7 +294,7 @@ void csv_datasource::parse_csv(T & stream,
|
|||
if (has_disk_index_) return;
|
||||
|
||||
std::vector<item_type> boxes;
|
||||
while (is_first_row || csv_utils::getline_csv(stream, csv_line, stream.widen(newline)))
|
||||
while (is_first_row || csv_utils::getline_csv(stream, csv_line, widened_newline))
|
||||
{
|
||||
if ((row_limit_ > 0) && (line_number++ > row_limit_))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue