گرافیک بهینه سازی مختصر بسته های PHP و PHP core.

Y.P.Y

Well-Known Member
سلام،
يک سري تغييرات و بهينه سازي هاي کوچيک براي سورس/موتور PHP جهت کارايي/performance بهتر:
PHP v5
کد:
[WinUtil.c - Line #37]
[اصلي]
int php_win32_check_trailing_space(const char * path, const int path_len) {
	if (path_len < 1) {
		return 1;
	}
	if (path) {
		if (path[0] == ' ' || path[path_len - 1] == ' ') {
			return 0;
		} else {
			return 1;
		}
	} else {
		return 0;
	}
}

[تغيير يافته]
static unsigned int php_win32_check_trailing_space(const char * path, const int path_len)
{
		if(!path)
		{
			return 0;
		}

		if((path_len < 1) || (path[0] != ' ') || (path[path_len - 1] != ' '))
		{
			return 1;
		}

	return 0;
}

کد:
[Inet.c/Inet.h - Line #79]
[اصلي]
int inet_aton(const char *cp, struct in_addr *inp) {
  inp->s_addr = inet_addr(cp);

  if (inp->s_addr == INADDR_NONE) {
          return 0;
  }

  return 1;
}
PHPAPI int inet_aton(const char *cp, struct in_addr *inp);

[تغيير يافته]
unsigned int inet_aton(const char *cp, struct in_addr *inp)
{

	  if((inp->s_addr= inet_addr(cp)) == INADDR_NONE)
	  {
			return 0;
	  }

	return 1;
}
PHPAPI unsigned int inet_aton(const char *cp, struct in_addr *inp);

کد:
[SendMail.c - Line #978]
[اصلي]
static int FormatEmailAddress(char* Buf, char* EmailAddress, char* FormatString) {
	char *tmpAddress1, *tmpAddress2;
	int result;

	if( (tmpAddress1 = strchr(EmailAddress, '<')) && (tmpAddress2 = strchr(tmpAddress1, '>'))  ) {
		*tmpAddress2 = 0; // terminate the string temporarily.
		result = snprintf(Buf, MAIL_BUFFER_SIZE, FormatString , tmpAddress1+1);
		*tmpAddress2 = '>'; // put it back the way it was.
		return result;
	} 
	return snprintf(Buf, MAIL_BUFFER_SIZE , FormatString , EmailAddress );
} /* end FormatEmailAddress() */
[تغيير يافته]
static int FormatEmailAddress(char* Buf, char* EmailAddress, char* FormatString)
{
	char *tmpAddress1, *tmpAddress2;
	static unsigned int result;

		if((tmpAddress1= strchr(EmailAddress, '<')) != SUCCESS && (tmpAddress2= strchr(tmpAddress1, '>')) != SUCCESS)
		{
			return snprintf(Buf, MAIL_BUFFER_SIZE , FormatString , EmailAddress );
		}

	*tmpAddress2= 0; // terminate the string temporarily.
	result= snprintf(Buf, MAIL_BUFFER_SIZE, FormatString , tmpAddress1+1);
	*tmpAddress2= '>'; // put it back the way it was.
	return result;
} /* end FormatEmailAddress() */

البته شبه و حوص فکر کردن ندارم، تغييرات جزيي انجام دادم. ولي جا براي بهينه سازي هاي جدي تر داره.
 

جدیدترین ارسال ها

بالا