From 4b3e1df51de2ff1b3e57dd4093f1b610afd60612 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Wed, 20 Jul 2016 02:10:27 -0400 Subject: [PATCH] registry: Check for canceled search prior to sorting results This gives a slightly noticeable performance improvement. --- src/registry/docsetregistry.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/registry/docsetregistry.cpp b/src/registry/docsetregistry.cpp index 3fc7848..33de7ea 100644 --- a/src/registry/docsetregistry.cpp +++ b/src/registry/docsetregistry.cpp @@ -149,10 +149,16 @@ void DocsetRegistry::_runQuery(const QString &query, const CancellationToken &to query, token), &MergeQueryResults); QList results = queryResultsFuture.result(); + + if (token.isCanceled()) + return; + std::sort(results.begin(), results.end()); - if (!token.isCanceled()) - emit queryCompleted(results); + if (token.isCanceled()) + return; + + emit queryCompleted(results); } // Recursively finds and adds all docsets in a given directory.