From b913aef726cf9aabb706e64fad03aa8bbd878601 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thiemo=20M=C3=A4ttig?= Date: Mon, 13 Oct 2014 19:07:30 +0200 Subject: [PATCH] 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 --- includes/db/ORMTable.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 ); } /** -- 2.20.1