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