From: Thiemo Mättig Date: Mon, 13 Oct 2014 17:07:30 +0000 (+0200) Subject: Rewrite ORMTable::unprefixFieldNames X-Git-Tag: 1.31.0-rc.0~13544^2 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=b913aef726cf9aabb706e64fad03aa8bbd878601;p=lhc%2Fweb%2Fwiklou.git Rewrite ORMTable::unprefixFieldNames This method is called a lot (~1000 times each time). It calls the callback function ~10 times per table, resulting in ~10000 calls of strlen. Which is just not necesarry. The string length does not change. Change-Id: I19194f1166da465a1c9ef4b2fb9cdaef4105a6f7 --- diff --git a/includes/db/ORMTable.php b/includes/db/ORMTable.php index 2f898b755b..ac27ee2716 100644 --- a/includes/db/ORMTable.php +++ b/includes/db/ORMTable.php @@ -783,7 +783,11 @@ class ORMTable extends DBAccessBase implements IORMTable { * @return array */ public function unprefixFieldNames( array $fieldNames ) { - return array_map( array( $this, 'unprefixFieldName' ), $fieldNames ); + $start = strlen( $this->fieldPrefix ); + + return array_map( function( $fieldName ) use ( $start ) { + return substr( $fieldName, $start ); + }, $fieldNames ); } /**