Re: [PATCH] string_offset access optimization

From: Date: Thu, 15 Jul 2010 22:18:34 +0000
Subject: Re: [PATCH] string_offset access optimization
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-49082@lists.php.net to get a copy of this message
Hi Dmitry, 2010/7/15 Dmitry Stogov <dmitry@zend.com> > Hi, > > Recently I noticed that reading of string offset is performed in two steps. > At first special string_offset variant of temporary_variable is created in > zend_fetch_dimension_address_read() and then the real string value is > created in _get_zval_ptr_var_string_offset(). > > I think we can create the real string in the first place. This makes 50% > speed-up on string offset reading operation and allows to eliminate some > checks and conditional brunches in VM. > > The patch is attached (don't forget to regenerate zend_vm_execute.h to test > it). However it changes behavior in one bogus case. > The following code now will emit "b" (currently it generates a fatal error > - cannot use string offset as an array). > > $str = "abs"; > var_dumo($str[1][0]); > > I think it's not a problem at all. > "b" makes sense because "abs"[1] -> "b" and "b"[0] > -> "b". > > I'm going to commit the patch in case of no objections. > > Thanks. Dmitry. > > The patch looks good, I did some tests, not found anything strange. Good simplyfication! :) -- Regards, Felipe Pena

« previous php.internals (#49082) next »