LanguageNameIndexer: Small cleanups
Change-Id: I24509b35c403dcdae94f921ccc9b82c2e9c78aa7
This commit is contained in:
committed by
jenkins-bot
parent
2a044e1e0a
commit
c79e0292aa
@@ -120,12 +120,12 @@ class LanguageNameIndexer extends Maintenance {
|
||||
// - shortest matches appear first, especially exact matches
|
||||
// Sort buckets by index
|
||||
ksort( $buckets );
|
||||
foreach ( $buckets as $index => &$bucketTypes ) {
|
||||
foreach ( $buckets as &$bucketTypes ) {
|
||||
$lengths[] = array_sum( array_map( 'count', $bucketTypes ) );
|
||||
// Ensure 'prefix' is before 'infix';
|
||||
krsort( $bucketTypes );
|
||||
// Ensure each bucket has entries sorted
|
||||
foreach ( $bucketTypes as $type => &$bucket ) {
|
||||
foreach ( $bucketTypes as &$bucket ) {
|
||||
ksort( $bucket );
|
||||
}
|
||||
}
|
||||
@@ -157,11 +157,11 @@ class LanguageNameIndexer extends Maintenance {
|
||||
}
|
||||
|
||||
private function generateFile( array $buckets ) {
|
||||
$template = <<<PHP
|
||||
$template = <<<'PHP'
|
||||
<?php
|
||||
// This file is generated by script!
|
||||
// This file is generated by a script!
|
||||
class LanguageNameSearchData {
|
||||
public static \$buckets = ___;
|
||||
public static $buckets = ___;
|
||||
}
|
||||
|
||||
PHP;
|
||||
@@ -170,7 +170,7 @@ PHP;
|
||||
$data = var_export( $buckets, true );
|
||||
$data = str_replace( "array (", '[', $data );
|
||||
$data = str_replace( "),", '],', $data );
|
||||
// Closing of the array, add correct indendation
|
||||
// Closing of the array, add correct indentation
|
||||
$data = preg_replace( "/\)$/", "\t]", $data );
|
||||
// Remove newlines after =>s
|
||||
$data = preg_replace( '/(=>)\s+(\[)/m', '\1 \2', $data );
|
||||
|
||||
Reference in New Issue
Block a user