Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53378 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19168 invoked from network); 20 Jun 2011 11:01:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2011 11:01:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:46533] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/C6-34681-C982FFD4 for ; Mon, 20 Jun 2011 07:01:48 -0400 Received: from localhost (xdebug.org [127.0.0.1]) by xdebug.org (Postfix) with ESMTPS id F413EDE13E; Mon, 20 Jun 2011 12:01:43 +0100 (BST) Date: Mon, 20 Jun 2011 12:01:43 +0100 (BST) X-X-Sender: derick@whisky To: Robert Eisele cc: internals@lists.php.net In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] Optimized smart strings From: derick@php.net (Derick Rethans) On Mon, 20 Jun 2011, Robert Eisele wrote: > PHP makes use of the smart string library. I've optimized the > smart_str_append_long() macro in order to save one division per cycle. At > the moment one modulo and one division is used. The optimized version uses > one division (which gets optimized away in most situations) and one > additional multiplication + subtraction. I've additionally added also a new > maco called smart_str_append_const(). This macro is used to append constant > strings with a sizeof()-1 instead of strlen() "call". I'd be glad to see > this change in 5.4. > > As I wrote in the earlier post, I'll deliver the patch in addition. > > PS: yes, this is a really small micro optimization. It is, but it is not going to break anything, so IMO a good idea to add. It would be awesome if we could document the whole smart_string API as well though; even though it's fairly simple, moar documentation is good! cheers, Derick -- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug