Optimize the code

KiamLaLuno - February 22, 2009 - 00:27
Project:Wordpress Import
Version:6.x-1.0
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:active
Description

The code must be optimized a little. Just to make an example, the code could be changed from

<?php
$module_name
= 'wordpress_import';
$dir = drupal_get_path('module', $module_name) .'/tests';
?>

to

<?php
$dir
= drupal_get_path('module', 'wordpress_import') .'/tests';
?>

especially when $module_name is used just once on the function code.

#1

KiamLaLuno - February 22, 2009 - 00:32

It would also be preferable to use if (is_null($r) {, rather than if ($r === NULL) {.

#2

KiamLaLuno - February 22, 2009 - 00:41

Also, if the string doesn't contain only spaces, and a zero, then

<?php
if ('' != trim($post)) {
 
// ...
}
?>

can be changed in

<?php
if (!trim($post)) {
 
// ...
}
?>

 
 

Drupal is a registered trademark of Dries Buytaert.