collation: Remove suppressWarnings() for getSortKey()
authorOri Livneh <ori@wikimedia.org>
Mon, 23 May 2016 22:43:16 +0000 (15:43 -0700)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 26 May 2016 16:43:44 +0000 (17:43 +0100)
Small optimization to IcuCollation::fetchFirstLetterData().

This used to suppress / restore warnings once per every letter of
every alphabet. The workaround for string casting and error
suppression is no longer needed as of PHP 5.3, in which the
bug was fixed.

Change-Id: Idd41a509858c0887df4f632b480b387bd74027b2

includes/collation/IcuCollation.php

index a374b13..f6a9dc7 100644 (file)
@@ -188,20 +188,11 @@ class IcuCollation extends Collation {
        }
 
        public function getSortKey( $string ) {
-               // intl extension produces non null-terminated
-               // strings. Appending '' fixes it so that it doesn't generate
-               // a warning on each access in debug php.
-               MediaWiki\suppressWarnings();
-               $key = $this->mainCollator->getSortKey( $string ) . '';
-               MediaWiki\restoreWarnings();
-               return $key;
+               return $this->mainCollator->getSortKey( $string );
        }
 
        public function getPrimarySortKey( $string ) {
-               MediaWiki\suppressWarnings();
-               $key = $this->primaryCollator->getSortKey( $string ) . '';
-               MediaWiki\restoreWarnings();
-               return $key;
+               return $this->primaryCollator->getSortKey( $string );
        }
 
        public function getFirstLetter( $string ) {