It's been a while, but it's good to be back. While poking through some code I found the ./phpmyfaq/inc/Helpder/Search.php function which is doing some neat pagination stuff of course. An idea for a performance improvement, for which I have yet to find any downsides, is to NOT loop through the pages of FAQs after the current FAQ, since that is effectively what happens right now. A unified diff implementing this change follows:
<diff file="./phpmyfaq/inc/PMF/Helper/Search.php">
--- phpmyfaq/inc/PMF/Helper/Search.php-orig 2013-06-26 12:32:58.000000000 -0600
+++ phpmyfaq/inc/PMF/Helper/Search.php 2013-07-24 21:58:05.399000000 -0600
@@ -270,7 +270,8 @@
foreach ($resultSet->getResultset() as $result) {
if ($displayedCounter >= $confPerPage) {
- continue;
+ //echo 'hi';continue;
+ break;
}
$counter++;
if ($counter <= $firstPage) {
</diff>
Basically the commented line is there for me to see what I did, but this change just replaces the single 'continue;' with a 'break;' which drops out of the loop. This matters to me when I get a resultset that is close to 500 pages long (or more for some search results). While I have not tried timing the difference in performance, it's pretty simple to see that the loop is running unnecessarily and can be optimized, hopefully without any drawbacks.
-dajoker
Performance increase in Helper/Search.php on big resultset
Moderator: Thorsten
Re: Performance increase in Helper/Search.php on big results
Hi,
awesome, I added it to 2.8.2
Thanks!
bye
Thorsten
awesome, I added it to 2.8.2
Thanks!
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist