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 |
Jump to:
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
It would also be preferable to use
if (is_null($r) {, rather thanif ($r === NULL) {.#2
Also, if the string doesn't contain only spaces, and a zero, then
<?phpif ('' != trim($post)) {
// ...
}
?>
can be changed in
<?phpif (!trim($post)) {
// ...
}
?>