miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Suggestions miniBB Support Forums / Suggestions /  
 

Suggestion for the pageChk function (to make it simpler / faster)

 
Author tom322
Active Member
#1 | Posted: 15 Jan 2019 19:39 
I also have suggestion about the pageChk function to make it less complicated / faster. Could you check if my suggestion is correct? The current function:

function pageChk($page,$numRows,$viewMax){
if($numRows>0 and ($page>PAGE1_OFFSET+1 or $page<PAGE1_OFFSET+1)){
$max=ceil($numRows/$viewMax)+PAGE1_OFFSET;
if ($page<PAGE1_OFFSET+1) return PAGE1_OFFSET+1;
elseif($page>$max) return $max;
else return $page;
}
else return PAGE1_OFFSET+1;
}
My proposed function:

function pageChk($page,$numRows,$viewMax){
if($numRows>0 and $page>PAGE1_OFFSET+1){
$max=ceil($numRows/$viewMax)+PAGE1_OFFSET;
if($page>$max) return $max;
else return $page;
}
else return PAGE1_OFFSET+1;
}

Author Paul
Lead Developer 
#2 | Posted: 16 Jan 2019 12:34 
Indeed this is the case I would prefer not to touch at all. The boolean code is fast in itself and you will not save any meaningful resource just cutting it off; but instead there could be a bug which wouldn't be visible straight. Right now I'm not sure and don't remember why it has been coded that way, but obviously it has its ground, and your updated code visibly is not the same as the original one.

Suggestions miniBB Support Forums / Suggestions /
 Suggestion for the pageChk function (to make it simpler / faster)
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Install the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑