mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:27:43 +00:00
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:
parent
88b168ff16
commit
b11b3c2f1c
4 changed files with 36 additions and 7 deletions
|
@ -11,12 +11,12 @@ namespace Reader {
|
|||
|
||||
ParserBehaviour operator&(ParserBehaviour left, ParserBehaviour right)
|
||||
{
|
||||
return static_cast<ParserBehaviour>(static_cast<u32>(left) & static_cast<u32>(right));
|
||||
return static_cast<ParserBehaviour>(to_underlying(left) & to_underlying(right));
|
||||
}
|
||||
|
||||
ParserBehaviour operator|(ParserBehaviour left, ParserBehaviour right)
|
||||
{
|
||||
return static_cast<ParserBehaviour>(static_cast<u32>(left) | static_cast<u32>(right));
|
||||
return static_cast<ParserBehaviour>(to_underlying(left) | to_underlying(right));
|
||||
}
|
||||
|
||||
void XSV::set_error(ReadError error)
|
||||
|
@ -43,8 +43,22 @@ Vector<String> XSV::headers() const
|
|||
return headers;
|
||||
}
|
||||
|
||||
void XSV::parse_preview()
|
||||
{
|
||||
reset();
|
||||
if ((m_behaviours & ParserBehaviour::ReadHeaders) != ParserBehaviour::None)
|
||||
read_headers();
|
||||
|
||||
while (!has_error() && !m_lexer.is_eof()) {
|
||||
if (m_rows.size() >= 10)
|
||||
break;
|
||||
m_rows.append(read_row());
|
||||
}
|
||||
}
|
||||
|
||||
void XSV::parse()
|
||||
{
|
||||
reset();
|
||||
if ((m_behaviours & ParserBehaviour::ReadHeaders) != ParserBehaviour::None)
|
||||
read_headers();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue