Skip to content

Loading…

Micro optimization #713

Merged
merged 1 commit into from

2 participants

@jails
Union of RAD member

while(list($key,$val) = each($data)); is about 7 times slower than it's equivalent foreach($data as $key => $val);

@gwoo gwoo merged commit 1a38527 into UnionOfRAD:dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 7, 2012
  1. @jails

    Micro optimization

    jails committed
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 data/source/Database.php
View
4 data/source/Database.php
@@ -1218,7 +1218,7 @@ protected function _cast($type, $value) {
protected function _createFields($data, $schema, $context) {
$fields = $values = array();
- while (list($field, $value) = each($data)) {
+ foreach ($data as $field => $value) {
$fields[] = $this->name($field);
$values[] = $this->value($value, isset($schema[$field]) ? $schema[$field] : array());
}
@@ -1230,7 +1230,7 @@ protected function _createFields($data, $schema, $context) {
protected function _updateFields($data, $schema, $context) {
$fields = array();
- while (list($field, $value) = each($data)) {
+ foreach ($data as $field => $value) {
$schema += array($field => array('default' => null));
$fields[] = $this->name($field) . ' = ' . $this->value($value, $schema[$field]);
}
Something went wrong with that request. Please try again.