mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-23 14:36:44 +02:00
Performance
- Sped up task sorting by skipping re-interpretation of certain data types.
This commit is contained in:
parent
e16b33745e
commit
8cbacdacf7
2 changed files with 17 additions and 21 deletions
|
@ -12,6 +12,7 @@ Features
|
||||||
+ Introduced a new filter optimization that recognizes filters with no 'OR', or
|
+ Introduced a new filter optimization that recognizes filters with no 'OR', or
|
||||||
'XOR' operators, includes IDs, but does not include UUIDs. This combination
|
'XOR' operators, includes IDs, but does not include UUIDs. This combination
|
||||||
means completed.data is not referenced.
|
means completed.data is not referenced.
|
||||||
|
+ Sped up task sorting by skipping re-interpretation of certain data types.
|
||||||
|
|
||||||
Bugs
|
Bugs
|
||||||
+ Fixed bug #964, where the 'projects' command showed the wrong priority labels
|
+ Fixed bug #964, where the 'projects' command showed the wrong priority labels
|
||||||
|
|
37
src/sort.cpp
37
src/sort.cpp
|
@ -76,10 +76,10 @@ static bool sort_compare (int left, int right)
|
||||||
int right_number;
|
int right_number;
|
||||||
std::string left_string;
|
std::string left_string;
|
||||||
std::string right_string;
|
std::string right_string;
|
||||||
time_t left_date;
|
|
||||||
time_t right_date;
|
|
||||||
float left_real;
|
float left_real;
|
||||||
float right_real;
|
float right_real;
|
||||||
|
char left_char;
|
||||||
|
char right_char;
|
||||||
|
|
||||||
std::vector <std::string>::iterator k;
|
std::vector <std::string>::iterator k;
|
||||||
for (k = global_keys.begin (); k != global_keys.end (); ++k)
|
for (k = global_keys.begin (); k != global_keys.end (); ++k)
|
||||||
|
@ -152,19 +152,20 @@ static bool sort_compare (int left, int right)
|
||||||
// Priority.
|
// Priority.
|
||||||
else if (field == "priority")
|
else if (field == "priority")
|
||||||
{
|
{
|
||||||
left_string = (*global_data)[left].get (field);
|
left_char = ((*global_data)[left].get (field))[0];
|
||||||
right_string = (*global_data)[right].get (field);
|
right_char = ((*global_data)[right].get (field))[0];
|
||||||
if (left_string == right_string)
|
|
||||||
|
if (left_char == right_char)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ascending)
|
if (ascending)
|
||||||
return (left_string == "" && right_string != "") ||
|
return (left_char == '\0' && right_char != '\0') ||
|
||||||
(left_string == "L" && (right_string == "M" || right_string == "H")) ||
|
(left_char == 'L' && (right_char == 'M' || right_char == 'H')) ||
|
||||||
(left_string == "M" && right_string == "H");
|
(left_char == 'M' && right_char == 'H');
|
||||||
|
|
||||||
return (left_string != "" && right_string == "") ||
|
return (left_char != '\0' && right_char == '\0') ||
|
||||||
(left_string == "M" && right_string == "L") ||
|
(left_char == 'M' && right_char == 'L') ||
|
||||||
(left_string == "H" && (right_string == "M" || right_string == "L"));
|
(left_char == 'H' && (right_char == 'M' || right_char == 'L'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Due Date.
|
// Due Date.
|
||||||
|
@ -182,13 +183,10 @@ static bool sort_compare (int left, int right)
|
||||||
if (left_string == right_string)
|
if (left_string == right_string)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
left_date = atoi (left_string.c_str ());
|
|
||||||
right_date = atoi (right_string.c_str ());
|
|
||||||
|
|
||||||
if (ascending)
|
if (ascending)
|
||||||
return left_date < right_date;
|
return left_string < right_string;
|
||||||
|
|
||||||
return left_date > right_date;
|
return left_string > right_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Date.
|
// Date.
|
||||||
|
@ -204,13 +202,10 @@ static bool sort_compare (int left, int right)
|
||||||
if (left_string == right_string)
|
if (left_string == right_string)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
left_date = atoi (left_string.c_str ());
|
|
||||||
right_date = atoi (right_string.c_str ());
|
|
||||||
|
|
||||||
if (ascending)
|
if (ascending)
|
||||||
return left_date < right_date;
|
return left_string < right_string;
|
||||||
|
|
||||||
return left_date > right_date;
|
return left_string > right_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Duration.
|
// Duration.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue