mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-21 16:53:08 +02:00
CmdInfo: Switched to use indices to make fewer string copies
This commit is contained in:
parent
5db328f95c
commit
f92219e5cd
1 changed files with 13 additions and 14 deletions
|
@ -524,33 +524,32 @@ int CmdInfo::execute (std::string& output)
|
||||||
if (context.config.getBoolean ("journal.info") &&
|
if (context.config.getBoolean ("journal.info") &&
|
||||||
undo.size () > 3)
|
undo.size () > 3)
|
||||||
{
|
{
|
||||||
// Scan the undo data for entries matching this task.
|
// Scan the undo data for entries matching this task, without making
|
||||||
std::string when;
|
// copies.
|
||||||
std::string previous;
|
|
||||||
std::string current;
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
long last_timestamp = 0;
|
long last_timestamp = 0;
|
||||||
while (i < undo.size ())
|
while (i < undo.size ())
|
||||||
{
|
{
|
||||||
when = undo[i++];
|
int when = i++;
|
||||||
previous = "";
|
int previous = -1;
|
||||||
if (undo[i].substr (0, 3) == "old")
|
|
||||||
previous = undo[i++];
|
|
||||||
|
|
||||||
current = undo[i++];
|
if (! undo[i].compare (0, 3, "old", 3))
|
||||||
|
previous = i++;
|
||||||
|
|
||||||
|
int current = i++;
|
||||||
i++; // Separator
|
i++; // Separator
|
||||||
|
|
||||||
if (current.find ("uuid:\"" + uuid) != std::string::npos)
|
if (undo[current].find ("uuid:\"" + uuid) != std::string::npos)
|
||||||
{
|
{
|
||||||
if (previous != "")
|
if (previous != -1)
|
||||||
{
|
{
|
||||||
int row = journal.addRow ();
|
int row = journal.addRow ();
|
||||||
|
|
||||||
ISO8601d timestamp (strtol (when.substr (5).c_str (), NULL, 10));
|
ISO8601d timestamp (strtol (undo[when].substr (5).c_str (), NULL, 10));
|
||||||
journal.set (row, 0, timestamp.toString (dateformat));
|
journal.set (row, 0, timestamp.toString (dateformat));
|
||||||
|
|
||||||
Task before (previous.substr (4));
|
Task before (undo[previous].substr (4));
|
||||||
Task after (current.substr (4));
|
Task after (undo[current].substr (4));
|
||||||
journal.set (row, 1, taskInfoDifferences (before, after, dateformat, last_timestamp, timestamp.toEpoch()));
|
journal.set (row, 1, taskInfoDifferences (before, after, dateformat, last_timestamp, timestamp.toEpoch()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue