mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Database: Use reverse iterator in lastLine
Now that we have the iterators, we can standardize on their use. Related to issue #245.
This commit is contained in:
parent
557fd4cb34
commit
6af1101ea2
1 changed files with 5 additions and 13 deletions
|
@ -253,20 +253,12 @@ std::vector <std::string> Database::files () const
|
||||||
// Walk backwards through the files until an interval is found.
|
// Walk backwards through the files until an interval is found.
|
||||||
std::string Database::lastLine ()
|
std::string Database::lastLine ()
|
||||||
{
|
{
|
||||||
if (_files.empty ())
|
auto it = rbegin ();
|
||||||
{
|
auto end = rend ();
|
||||||
initializeDatafiles ();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector <Datafile>::reverse_iterator ri;
|
while (it != end)
|
||||||
for (ri = _files.rbegin (); ri != _files.rend (); ri++)
|
if (! it->empty ())
|
||||||
{
|
return *it;
|
||||||
auto line = ri->lastLine ();
|
|
||||||
if (! line.empty ())
|
|
||||||
{
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue