diff options
author | Robin Appelman <robin@icewind.nl> | 2021-03-10 18:46:18 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2021-03-11 14:49:57 +0100 |
commit | 424db15deaef20856e29ba1c886f06864a393eea (patch) | |
tree | 26b9df80afe012ea2e8ecde06302b2346f73a78c /lib/private/Search | |
parent | 95cddb84e2d07f105d7120a4f7b37c65419c0943 (diff) | |
download | nextcloud-server-424db15deaef20856e29ba1c886f06864a393eea.tar.gz nextcloud-server-424db15deaef20856e29ba1c886f06864a393eea.zip |
limit constructing of result objects in file search
even thought we currently have no proper way of limiting the search itself, we can at least limit the construction of the result objects.
this saves about 40% of the time spend in the search request in my local testing
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Search')
-rw-r--r-- | lib/private/Search/Provider/File.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/Search/Provider/File.php b/lib/private/Search/Provider/File.php index b4e35d374ca..688b6ad1e91 100644 --- a/lib/private/Search/Provider/File.php +++ b/lib/private/Search/Provider/File.php @@ -39,14 +39,23 @@ class File extends \OCP\Search\Provider { /** * Search for files and folders matching the given query + * * @param string $query + * @param int|null $limit + * @param int|null $offset * @return \OCP\Search\Result[] * @deprecated 20.0.0 */ - public function search($query) { + public function search($query, int $limit = null, int $offset = null) { + if ($offset === null) { + $offset = 0; + } \OC_Util::setupFS(); $files = Filesystem::search($query); $results = []; + if ($limit !== null) { + $files = array_slice($files, $offset, $offset + $limit); + } // edit results foreach ($files as $fileData) { // skip versions |