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.
|
||||
std::string Database::lastLine ()
|
||||
{
|
||||
if (_files.empty ())
|
||||
{
|
||||
initializeDatafiles ();
|
||||
}
|
||||
auto it = rbegin ();
|
||||
auto end = rend ();
|
||||
|
||||
std::vector <Datafile>::reverse_iterator ri;
|
||||
for (ri = _files.rbegin (); ri != _files.rend (); ri++)
|
||||
{
|
||||
auto line = ri->lastLine ();
|
||||
if (! line.empty ())
|
||||
{
|
||||
return line;
|
||||
}
|
||||
}
|
||||
while (it != end)
|
||||
if (! it->empty ())
|
||||
return *it;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue