LanguageNameSearch.php: Minor cleanup

Change-Id: If031c59fee64ad6e51dedd3328aec7eca6ed0019
This commit is contained in:
Reedy
2021-11-25 23:33:01 +00:00
committed by jenkins-bot
parent 72c8cdb40b
commit b7e881be0a

View File

@@ -63,13 +63,10 @@ class LanguageNameSearch {
} }
$index = self::getIndex( $searchKey ); $index = self::getIndex( $searchKey );
$bucketsForIndex = []; $bucketsForIndex = LanguageNameSearchData::$buckets[$index] ?? [];
if ( isset( LanguageNameSearchData::$buckets[$index] ) ) {
$bucketsForIndex = LanguageNameSearchData::$buckets[$index];
}
// types are 'prefix', 'infix' (in this order!) // types are 'prefix', 'infix' (in this order!)
foreach ( $bucketsForIndex as $bucketType => $bucket ) { foreach ( $bucketsForIndex as $bucket ) {
foreach ( $bucket as $name => $code ) { foreach ( $bucket as $name => $code ) {
// We can skip checking languages we already have in the list // We can skip checking languages we already have in the list
if ( isset( $results[ $code ] ) ) { if ( isset( $results[ $code ] ) ) {
@@ -119,11 +116,11 @@ class LanguageNameSearch {
if ( $codepoint < 4000 ) { if ( $codepoint < 4000 ) {
// For latin etc. we need smaller buckets for speed // For latin etc. we need smaller buckets for speed
return $codepoint; return $codepoint;
} else { }
// Try to group names of same script together // Try to group names of same script together
return $codepoint - ( $codepoint % 1000 ); return $codepoint - ( $codepoint % 1000 );
} }
}
/** /**
* Get the code point of first letter of string * Get the code point of first letter of string
@@ -143,7 +140,8 @@ class LanguageNameSearch {
$number = $thisValue; $number = $thisValue;
break; break;
} else { }
// Codepoints larger than 127 are represented by multi-byte sequences // Codepoints larger than 127 are represented by multi-byte sequences
if ( $values === [] ) { if ( $values === [] ) {
// 224 is the lowest non-overlong-encoded codepoint. // 224 is the lowest non-overlong-encoded codepoint.
@@ -165,7 +163,6 @@ class LanguageNameSearch {
break; break;
} }
} }
}
return $number; return $number;
} }