performance: Do not use Pig to extract raw line content
This commit is contained in:
13
src/Task.cpp
13
src/Task.cpp
@@ -580,13 +580,14 @@ void Task::parse (const std::string& input)
|
|||||||
|
|
||||||
if (input[0] == '[')
|
if (input[0] == '[')
|
||||||
{
|
{
|
||||||
Pig pig (input);
|
// Not using Pig to parse here (which would be idiomatic), because we
|
||||||
std::string line;
|
// don't need to differentiate betwen utf-8 and normal characters.
|
||||||
if (pig.skip ('[') &&
|
// Pig's scanning the string can be expensive.
|
||||||
pig.getUntil (']', line) &&
|
auto ending_bracket = input.find_last_of (']');
|
||||||
pig.skip (']') &&
|
if (ending_bracket != std::string::npos)
|
||||||
(pig.skip ('\n') || pig.eos ()))
|
|
||||||
{
|
{
|
||||||
|
std::string line = input.substr(1, ending_bracket);
|
||||||
|
|
||||||
if (line.length () == 0)
|
if (line.length () == 0)
|
||||||
throw std::string ("Empty record in input.");
|
throw std::string ("Empty record in input.");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user