MyBB Community Forums

Full Version: Hooks in xmlhttp.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
The time it takes is just too too too short. Unless you did something like mt_rand + time() and something else inside the if condition, you're not really slowing down the script significantly. (even though it would be good practice to do exit; when the script should actually exit)
(2010-08-18, 10:24 AM)marines Wrote: [ -> ]
(2010-08-18, 02:21 AM)Ryan Gordon Wrote: [ -> ]
$i = 3;

if($i == 0)
{
  // This won't get executed
}
else if($i == 1)
{
   // This won't get executed
   exit;
}
else if($i == 2)
{
   // This won't get executed
}
else if($i == 3)
{
   // This will get executed
}
else if($i == 4)
{
  // This won't get executed
}
else if($i == 5)
{
  // This won't get executed
  exit;
}
else
{
  // this won't get executed
}

Yes, but:
$i = 3;

if($i == 0) // <- this will be executed
{
  // This won't get executed
}
else if($i == 1) // <- this will be executed
{
   // This won't get executed
   exit;
}
else if($i == 2) // <- this will be executed
{
   // This won't get executed
}
else if($i == 3) // <- this will be executed
{
   // This will get executed
}
else if($i == 4) // <- this will be executed TOO
{
  // This won't get executed
}
else if($i == 5) // <- this will be executed TOO
{
  // This won't get executed
  exit;
}
else
{
  // this won't get executed
}

It's rather unneccessary. Putting exit in the end of ech action is not a big deal.

$i = 3;

if($i == 0) // <- this will be executed
{
  // This won't get executed
  exit;
}
else if($i == 1) // <- this will be executed
{
   // This won't get executed
   exit;
}
else if($i == 2) // <- this will be executed
{
   // This won't get executed
   exit;
}
else if($i == 3) // <- this will be executed
{
   // This will get executed
   exit;
}
else if($i == 4) // <- this will NOT be executed now
{
  // This won't get executed
  exit;
}
else if($i == 5) // <- this will NOT be executed now
{
  // This won't get executed
  exit;
}
else
{
  // this won't get executed
}

Am I wrong? Perhaps it looks silly but it really takes time which is very valuable as Pirata Nervo said.

Really now? We're talking like nanoseconds of difference. Not going to waste my time to save you a couple of nanoseconds. There's much more efficient ways to optimize MyBB in the long run.


(2010-08-18, 10:24 AM)marines Wrote: [ -> ]Comming back to the topic. I see but xmlhttp.php has one hook while others have more. I'm just suggesting. Smile

Like?
xmlhttp may have only one hook, but it lets you do whatever you want with xmlhttp

(2010-08-18, 04:50 PM)Ryan Gordon Wrote: [ -> ]Really now? We're talking like nanoseconds of difference. Not going to waste my time to save you a couple of nanoseconds. There's much more efficient ways to optimize MyBB in the long run.

Hell yeah, it'd really take ages to fix it. -.- Yes, leave it because it takes only nanoseconds more execution time. Pathetic. EOT

(2010-08-18, 10:24 AM)marines Wrote: [ -> ]Like?

Like member.php.

frostschutz, but to make little modification of any action you have to copy whole action to your plugin and modify it then.
(2010-08-18, 05:11 PM)marines Wrote: [ -> ]frostschutz, but to make little modification of any action you have to copy whole action to your plugin and modify it then.

At least it's possible at all; others aren't so lucky and have no choice but to modify code. Besides, it is possible to modify the output of the other actions (Output Control), so you may not have to copy after all.
(2010-08-18, 05:11 PM)marines Wrote: [ -> ]
(2010-08-18, 04:50 PM)Ryan Gordon Wrote: [ -> ]Really now? We're talking like nanoseconds of difference. Not going to waste my time to save you a couple of nanoseconds. There's much more efficient ways to optimize MyBB in the long run.

Hell yeah, it'd really take ages to fix it. -.- Yes, leave it because it takes only nanoseconds more execution time. Pathetic. EOT

Please calm down. My reasoning is very legitimate.

(2010-08-18, 05:11 PM)marines Wrote: [ -> ]
(2010-08-18, 04:50 PM)Ryan Gordon Wrote: [ -> ]Like?

Like member.php.

No, as in, where do you want the plugin hooks in xmlhttp, because I can't read your mind and guarantee your satisfaction unless you tell me.
My guess is one per action and move the current hook to the end of the file as he said in the first post. Would probably be good but an exit; would be required for the actions without exit; (except the ones that shouldn't have one) to not run more than one hook per instance of xmlhttp.php
Exactly as Pirata Nervo said.
Pages: 1 2