renderer: use iterator rather than creating vectors

Creating vectors from the FrameHashCache was one of the slowest functions in the program, this should be significantly faster.
This commit is contained in:
itsmattkc
2021-07-11 16:47:12 -07:00
parent 9b0b3962fe
commit 8a58ee2bdb
9 changed files with 126 additions and 95 deletions
+46
View File
@@ -22,6 +22,7 @@
#define TIMERANGE_H
#include "rational.h"
#include "timecodefunctions.h"
namespace olive {
@@ -127,16 +128,61 @@ public:
return array_.last();
}
const TimeRange& at(int index) const
{
return array_.at(index);
}
const QVector<TimeRange>& internal_array() const
{
return array_;
}
bool operator==(const TimeRangeList &rhs) const
{
return array_ == rhs.array_;
}
private:
QVector<TimeRange> array_;
};
class TimeRangeListFrameIterator
{
public:
TimeRangeListFrameIterator(const TimeRangeList &list, const rational &timebase);
bool GetNext(rational *out);
QVector<rational> ToVector() const
{
TimeRangeListFrameIterator copy(list_, timebase_);
QVector<rational> times;
rational r;
while (copy.GetNext(&r)) {
times.append(r);
}
return times;
}
int size();
private:
void UpdateIndexIfNecessary();
TimeRangeList list_;
rational timebase_;
rational current_;
int index_;
int size_;
};
uint qHash(const TimeRange& r, uint seed = 0);
}