jenkins-bot has submitted this change and it was merged.

Change subject: use substr instead of preg_match to check for '_id'
......................................................................


use substr instead of preg_match to check for '_id'

For slighter faster performance gain

Change-Id: Iba8928f5a06eb5f83e601c41cb3467923575ae08
---
M includes/Data/ObjectManager.php
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  EBernhardson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Data/ObjectManager.php b/includes/Data/ObjectManager.php
index 61b44d2..4e01c48 100644
--- a/includes/Data/ObjectManager.php
+++ b/includes/Data/ObjectManager.php
@@ -557,7 +557,7 @@
                foreach( $sortFields as $field ) {
                        $value = $row[$field];
 
-                       if ( strlen( $value ) == 16 && preg_match( '/_id$/', 
$field ) ) {
+                       if ( strlen( $value ) == 16 && substr( $field, -3 ) === 
'_id' ) {
                                $value = UUID::create( $value )->getHex();
                        }
                        $offsetFields[] = $value;
@@ -1048,7 +1048,7 @@
                foreach( $attributes as $key => $attr ) {
                        if ( $attr instanceof \Flow\Model\UUID ) {
                                $attributes[$key] = $attr->getHex();
-                       } elseif ( strlen( $attr ) == 16 && preg_match( 
'/_id$/', $key ) ) {
+                       } elseif ( strlen( $attr ) == 16 && substr( $key, -3 ) 
=== '_id' ) {
                                $uuid = new \Flow\Model\UUID( $attr );
                                $attributes[$key] = $uuid->getHex();
                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/99588
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iba8928f5a06eb5f83e601c41cb3467923575ae08
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to