Optimizing add_assoc_* with static keys (WAS: Re: [PHP-DEV] [PATCH] array_combine is not binary-key safe)
| From: | Matt W | Date: | Sun, 23 Jul 2006 03:45:27 +0000 |
| Subject: | Optimizing add_assoc_* with static keys (WAS: Re: [PHP-DEV] [PATCH] array_combine is not binary-key safe) | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-24892@lists.php.net to get a copy of this message | ||
Hi Richard,
Replacement script made it pretty simple I guess. :-) But sizeof("key")+1
should just be sizeof("key") (which == strlen("key")+1).
Are there any uses of add_u_assoc_* with hard-coded keys?
These changes make things look a little messy, you think? The string is in
2 places, etc... (Maybe why it wasn't done in the first place?) Seems like
that ZEND_STRS() macro you mentioned would work well. Or maybe cleanest
would be some new add_static_assoc_* macros (and _u versions if needed), or
some other naming convention, that uses sizeof() instead of strlen()+1.
What do the main devs think?
Matt
----- Original Message -----
From: "Richard Quadling"
Sent: Saturday, July 22, 2006
> Hi. Sorry about the delay. Had a blonde moment.
>
> I've used a small script to process the CVS. There are 420 changes!!!
>
> I've used the following regexps for a search/replace ...
>
> $s_search =
'`add_assoc_(bool|double|long|null|resource|rt_stringl|rt_string|stringl|str
ing|unicodel|unicode|zval)*\(([^,]*),
> "(.*?)",`i';
> $s_replace = 'add_assoc_$1_ex($2, "$3", sizeof("$3")+1,';
>
> Everything SEEMS to look ok. Until I've got MS VC Express Edition
> compiling ok, this patch is UNTESTED!! (Sorry about that).
>
> Files changed.
>
> php-src/ext/bz2/bz2.c
> php-src/ext/calendar/calendar.c
> php-src/ext/curl/multi.c
> php-src/ext/curl/streams.c
> php-src/ext/date/php_date.c
> php-src/ext/dbase/dbase.c
> php-src/ext/exif/exif.c
> php-src/ext/fbsql/php_fbsql.c
> php-src/ext/fdf/fdf.c
> php-src/ext/gd/gd.c
> php-src/ext/gmp/gmp.c
> php-src/ext/hwapi/hwapi.cpp
> php-src/ext/iconv/iconv.c
> php-src/ext/interbase/ibase_blobs.c
> php-src/ext/interbase/ibase_query.c
> php-src/ext/interbase/ibase_service.c
> php-src/ext/ldap/ldap.c
> php-src/ext/mbstring/mbstring.c
> php-src/ext/oci8/oci8_interface.c
> php-src/ext/openssl/openssl.c
> php-src/ext/pdo/pdo_stmt.c
> php-src/ext/pdo_mysql/mysql_statement.c
> php-src/ext/pdo_pgsql/pgsql_statement.c
> php-src/ext/pdo_sqlite/sqlite_statement.c
> php-src/ext/pgsql/pgsql.c
> php-src/ext/posix/posix.c
> php-src/ext/session/session.c
> php-src/ext/soap/php_http.c
> php-src/ext/sockets/sockets.c
> php-src/ext/standard/basic_functions.c
> php-src/ext/standard/datetime.c
> php-src/ext/standard/dns.c
> php-src/ext/standard/file.c
> php-src/ext/standard/html.c
> php-src/ext/standard/image.c
> php-src/ext/standard/microtime.c
> php-src/ext/standard/proc_open.c
> php-src/ext/standard/streamsfuncs.c
> php-src/ext/standard/string.c
> php-src/ext/standard/url.c
> php-src/ext/sysvmsg/sysvmsg.c
> php-src/main/output.c
> php-src/main/streams/filter.c
> php-src/main/streams/memory.c
> php-src/main/streams/xp_socket.c
>
>
> Patch is available at
>
> http://rquadling.phpnet.us/add_assoc_xxx__to__add_assoc_xxx_ex__diff.txt
>
> Regards,
>
> Richard Quadling.