#6525: Deprecate ife(), a(), am(), r(), up(), low(), and e()
---------------------------------------------------+------------------------
    Reporter:  michaelc                            |          Type:  Bug      
      Status:  new                                 |      Priority:  Low      
   Milestone:  1.3.x.x                             |     Component:  Core Libs
     Version:  1.2 Final                           |      Severity:  Minor    
    Keywords:  deprecate ife am a r up low echo e  |   Php_version:  PHP 5    
Cake_version:                                      |  
---------------------------------------------------+------------------------
 These functions are inefficient and are already implemented at the
 language level:[[BR]]
 fe(), a(), am(), r(), up(), low(), and e()[[BR]]
 [[BR]]
 (All tests performed using a simple testing script, from the command line,
 PHP 5.1.6 and at 1,000,000 iterations).[[BR]]
 [[BR]]
 {{{ife($i%2, '', '')}}} vs {{{$i%2?'':''}}}[[BR]]
 Test 1 took 0.83274698257446 seconds to run.[[BR]]
 Test 2 took 0.15461993217468 seconds to run.[[BR]]
 (note also that the function is not quite the equivalent to the language
 construct, as both options are evaluated in the case of the function -
 compare "{{{$i = 0;echo ife(false,($i = $i+1),$i);}}}" with "{{{$i =
 0;echo (false?($i = $i+1):$i);}}}".  I regard the functionality of the ife
 function as less useful.)[[BR]]
 [[BR]]
 {{{a(1,2,3,4,5)}}} vs {{{array(1,2,3,4,5)}}}[[BR]]
 Test 1 took 0.90345978736877 seconds to run.[[BR]]
 Test 2 took 0.45615005493164 seconds to run.[[BR]]
 [[BR]]
 {{{am(array(1,2,3,4,5), array())}}} vs {{{array_merge(array(1,2,3,4,5),
 array())}}}[[BR]]
 Test 1 took 5.5314269065857 seconds to run.[[BR]]
 Test 2 took 1.2870719432831 seconds to run.[[BR]]
 (note that these functions are not completely equivalent if you are
 running PHP 5 - am() acts equivalent to the older PHP 4 function, and
 silently converts non-array arguments for you)[[BR]]
 [[BR]]
 {{{r('','','')}}} vs {{{str_replace('','','')}}}[[BR]]
 Test 1 took 1.1455109119415 seconds to run.[[BR]]
 Test 2 took 0.46572494506836 seconds to run.[[BR]]
 (also run with {{{'a', '', 'a'}}}, for purists)[[BR]]
 Test 1 took 1.2162089347839 seconds to run.[[BR]]
 Test 2 took 0.4943380355835 seconds to run.[[BR]]
 [[BR]]
 {{{up('')}}} vs {{{strtoupper('')}}}[[BR]]
 Test 1 took 0.52809000015259 seconds to run.[[BR]]
 Test 2 took 0.28283596038818 seconds to run.[[BR]]
 [[BR]]
 {{{low('')}}} vs {{{strtolower('')}}}[[BR]]
 Test 1 took 0.53930997848511 seconds to run.[[BR]]
 Test 2 took 0.27885103225708 seconds to run.[[BR]]
 [[BR]]
 {{{e('')}}} vs {{{echo('')}}}[[BR]]
 Test 1 took 0.3783860206604 seconds to run.[[BR]]
 Test 2 took 0.076194047927856 seconds to run.[[BR]]
 [[BR]]
 {{{aa()}}} is also suspect (most cases that I can think of should be using
 array_combine to perform something like it), but as it has no single
 function language level support at this time, I'll leave it be.  It does,
 however, remind me somewhat of an inverse of Intercal's mingle operator.
 For completeness:[[BR]]
 {{{aa(1,6,2,7,3,8,4,9,5,0)}}} vs {{{array_combine(array(1,2,3,4,5),
 array(6,7,8,9,0))}}}[[BR]]
 Test 1 took 4.6495821475983 seconds to run.[[BR]]
 Test 2 took 1.4624469280243 seconds to run.[[BR]]
 (both functions returned the same result)[[BR]]

-- 
Ticket URL: <https://trac.cakephp.org/ticket/6525>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to tickets-cakephp@googlegroups.com
To unsubscribe from this group, send email to 
tickets-cakephp+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to