PHP Classes

Optimization

Recommend this page to a friend!

      PHP WOL Wake On LAN  >  All threads  >  Optimization  >  (Un) Subscribe thread alerts  
Subject:Optimization
Summary:A little change to optimizate the class
Messages:3
Author:Ruben Arroyo
Date:2014-10-08 14:38:04
 

  1. Optimization   Reply   Report abuse  
Picture of Ruben Arroyo Ruben Arroyo - 2014-10-08 14:38:04
I don't know if "gethotbyname" is a fast function, but you can change this:

if (gethostbyname($addr) == $addr) {
self::throwError('Error: Domain name is unresolvable or IP address is invalid!');
} else {
$addr = gethostbyname($addr);
}


For this:

$originalAddr = gethostbyname($addr);
if ($originalAddr == $addr) {
self::throwError('Error: Domain name is unresolvable or IP address is invalid!');
} else {
$addr = $originalAddr;
}


Regards.

  2. Re: Optimization   Reply   Report abuse  
Picture of Radovan Janjic Radovan Janjic - 2014-10-08 18:37:50 - In reply to message 1 from Ruben Arroyo
Hi Ruben,

You're absolutely right!

I'll commit this change now.

"gethostbyname" is not good for performance, especially when used twice unnecessarily.

Thanks a lot,
Radovan.

  3. Re: Optimization   Reply   Report abuse  
Picture of Ruben Arroyo Ruben Arroyo - 2014-10-09 20:01:50 - In reply to message 2 from Radovan Janjic
you're welcome!

Regards :)