Spreadsheet: Make the XSV parser start with a preview parse

Instead of parsing the whole document. That's really wasteful and
super slow.
This commit is contained in:
Ali Mohammad Pur 2021-06-16 08:34:19 +04:30 committed by Ali Mohammad Pur
commit b11b3c2f1c
Notes: sideshowbarker 2024-07-18 12:09:50 +09:00
4 changed files with 36 additions and 7 deletions

View file

@ -147,7 +147,7 @@ auto CSVImportDialogPage::make_reader() -> Optional<Reader::XSV>
if (should_trim_trailing)
behaviours = behaviours | Reader::ParserBehaviour::TrimTrailingFieldSpaces;
return Reader::XSV(m_csv, traits, behaviours);
return Reader::XSV(m_csv, move(traits), behaviours);
};
void CSVImportDialogPage::update_preview()
@ -195,6 +195,7 @@ Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(String
NonnullRefPtrVector<Sheet> sheets;
if (reader.has_value()) {
reader->parse();
if (reader.value().has_error())
return String::formatted("CSV Import failed: {}", reader.value().error_string());