php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50157 [patch] Replace !strlen(...) with !*...
Submitted: 2009-11-12 14:26 UTC Modified: 2010-06-20 23:54 UTC
From: jille at hexon dot cx Assigned:
Status: Wont fix Package: Performance problem
PHP Version: 6SVN-2009-11-12 (SVN) OS: n/a
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-11-12 14:26 UTC] jille at hexon dot cx
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);
        }



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-20 23:54 UTC] felipe@php.net
-Status: Open +Status: Wont fix
 [2010-06-20 23:54 UTC] felipe@php.net
Old trunk related.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Apr 15 03:01:24 2021 UTC