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:
Shaun Ruffell 2019-12-23 04:07:08 -06:00 committed by lauft
parent 557fd4cb34
commit 6af1101ea2

View file

@ -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 "";
} }