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