#50157 [NEW]: [patch] Replace !strlen(...) with !*...
| From: | jille at hexon dot cx | Date: | Thu, 12 Nov 2009 14:26:46 +0000 |
| Subject: | #50157 [NEW]: [patch] Replace !strlen(...) with !*... | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-144529@lists.php.net to get a copy of this message | ||
From: jille at hexon dot cx
Operating system: n/a
PHP version: 6SVN-2009-11-12 (SVN)
PHP Bug Type: Performance problem
Bug description: [patch] Replace !strlen(...) with !*...
Description:
------------
The patch is self-explanatory. (And easier to read than a description).
It provides a (real little) performance improvement; but it is mainly for
the idea.
Reproduce code:
---------------
Index: ext/standard/http.c
===================================================================
--- ext/standard/http.c (revision 290576)
+++ ext/standard/http.c (working copy)
@@ -50,7 +50,7 @@
if (!arg_sep) {
arg_sep = INI_STR("arg_separator.output");
- if (!arg_sep || !strlen(arg_sep)) {
+ if (!arg_sep || !*arg_sep) {
arg_sep = URL_DEFAULT_ARG_SEP;
}
}
Index: ext/pdo_dblib/dblib_stmt.c
===================================================================
--- ext/pdo_dblib/dblib_stmt.c (revision 290576)
+++ ext/pdo_dblib/dblib_stmt.c (working copy)
@@ -118,7 +118,7 @@
S->cols[i].coltype = dbcoltype(H->link, i+1);
S->cols[i].name = (char*)dbcolname(H->link, i+1);
- if (!strlen(S->cols[i].name)) {
+ if (!*(S->cols[i].name)) {
if (j) {
spprintf(&tmp, 0, "computed%d",
j++);
strlcpy(S->cols[i].name, tmp,
strlen(tmp)+1);
Index: ext/mbstring/mbstring.c
===================================================================
--- ext/mbstring/mbstring.c (revision 290576)
+++ ext/mbstring/mbstring.c (working copy)
@@ -2899,7 +2899,7 @@
i--;
}
- if (_from_encodings != NULL &&
!strlen(_from_encodings)) {
+ if (_from_encodings != NULL && !*_from_encodings)
{
efree(_from_encodings);
_from_encodings = NULL;
}
Index: ext/dba/dba.c
===================================================================
--- ext/dba/dba.c (revision 290576)
+++ ext/dba/dba.c (working copy)
@@ -457,7 +457,7 @@
{
dba_handler *hptr;
- if (!strlen(new_value)) {
+ if (!*new_value) {
DBA_G(default_hptr) = NULL;
return OnUpdateString(entry, new_value, new_value_length,
mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
}
--
Edit bug report at http://bugs.php.net/?id=50157&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50157&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50157&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50157&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50157&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50157&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50157&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50157&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50157&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50157&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50157&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50157&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50157&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50157&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50157&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50157&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50157&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50157&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50157&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50157&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50157&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50157&r=mysqlcfg