Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2017-08-13 17:35:55 +0300
committerKacper Michajłow <kasper93@gmail.com>2017-08-13 23:24:42 +0300
commit620d8e5bef3e071aa0a2e0d3d5b49f71f45ed712 (patch)
treecfab98f52884f2b2c861701f5c2c798baadd697f
parentfa051343815bb72df9505b893ccdde2e828a6e2e (diff)
Subtitles: Use std::sort instead qsort.
It is a lot faster.
-rw-r--r--src/Subtitles/RTS.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Subtitles/RTS.cpp b/src/Subtitles/RTS.cpp
index b062e16e4..f03141f1f 100644
--- a/src/Subtitles/RTS.cpp
+++ b/src/Subtitles/RTS.cpp
@@ -2939,6 +2939,10 @@ STDMETHODIMP_(bool) CRenderedTextSubtitle::IsAnimated(POSITION pos)
struct LSub {
int idx, layer, readorder;
+
+ bool operator <(const LSub& rhs) const {
+ return (layer == rhs.layer) ? readorder < rhs.readorder : layer < rhs.layer;
+ }
};
static int lscomp(const void* ls1, const void* ls2)
@@ -2985,14 +2989,12 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d
CAtlArray<LSub> subs;
for (ptrdiff_t i = 0, j = stss->subs.GetCount(); i < j; i++) {
- LSub ls;
- ls.idx = stss->subs[i];
- ls.layer = GetAt(stss->subs[i]).layer;
- ls.readorder = GetAt(stss->subs[i]).readorder;
- subs.Add(ls);
+ const auto idx = stss->subs[i];
+ const auto& sts_entry = GetAt(idx);
+ subs.Add({ idx, sts_entry.layer, sts_entry.readorder });
}
- qsort(subs.GetData(), subs.GetCount(), sizeof(LSub), lscomp);
+ std::sort(subs.GetData(), subs.GetData() + subs.GetCount());
for (ptrdiff_t i = 0, j = subs.GetCount(); i < j; i++) {
int entry = subs[i].idx;