#41747 [NEW]: Performance Issue with Array Removals
| From: | martinmrozster at gmail dot com | Date: | Wed, 20 Jun 2007 09:08:37 +0000 |
| Subject: | #41747 [NEW]: Performance Issue with Array Removals | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-113952@lists.php.net to get a copy of this message | ||
From: martinmrozster at gmail dot com
Operating system: Linux 2.6
PHP version: 5.2.3
PHP Bug Type: Performance problem
Bug description: Performance Issue with Array Removals
Description:
------------
FOR THE LOVE OF GOD AND ALL THAT IS HOLY
I can't believe your insane stupidity. You are telling me that the
only way of REMOVING AN OBJECT FROM AN ARRAY IS TO USE YOUR OWN CODE?!
WHO IN THEIR RIGHT MIND WRITES A _____HIGH_LEVEL____ LANGUAGE AND
EXCLUDES THE MOST BASIC ARRAY FUNCTIONALITY?! WHERE IN GODS NAME DO
YOU GET THE IDEA THAT YOU ARE EVEN ALLOWED TO LIVE?!?!?!
I HAVE SPENT THE LAST HOUR FINDING OUT THAT unset() DOES NOT UPDATE
THE INICES IN AN ARRAY THAT YOU REMOVE AN OBJECT FROM - I MEAN JESUS
FUCKING CHRIST I THIS IS SO FAR BEYOND INSANE THAT YOU SHOULD BE SHOT
IN THE FACE AND LEFT TO DIE A HORRIBLE PAINFUL DEATH.
Lets calm down for a second and just think to ourselves....
Objective-C NSArray: [obj removeObjectAtIndex:] [arr removeObject]
[arr removeObjectsInRange] AND MORE
.NET: array.removeAt(), array.remove(), array.removeRange, and
FRIENDS.
Ruby: array.remove, array.remove_at
JavaScript: array.splice(index, howMany)
CoreFoundation: CFArrayRemove()
PERL: splice
PHP: INSERT FUNCTION HERE, LIKE, OH I DUNNO, MINE:
function array_remove(&$array, $key) {
$newArray = array();
foreach($array as $dumbassFuckingKey=>$value) {
if($dumbassFuckingKey != $key) {
$newArray[] = $value;
}
}
$array = $newArray;
}
Reproduce code:
---------------
function array_remove(&$array, $key) {
$newArray = array();
foreach($array as $dumbassFuckingKey=>$value) {
if($dumbassFuckingKey != $key) {
$newArray[] = $value;
}
}
$array = $newArray;
}
Expected result:
----------------
Well, I EXPECTED YOU TO PROVIDE ME A FUCKING FUNCTION TO REMOVE A VALUE
FROM A GOD DAMNED ARRAY.
Actual result:
--------------
YOU DIDNT.
--
Edit bug report at http://bugs.php.net/?id=41747&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41747&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41747&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41747&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41747&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=41747&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41747&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41747&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41747&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41747&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41747&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=41747&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=41747&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41747&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41747&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41747&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41747&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41747&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41747&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41747&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41747&r=mysqlcfg