Refactor complex ternary operation

Change-Id: I1b6cc1cf0348bc7e19f9f327c7a3d6d936cfaaf2
This commit is contained in:
Siebrand Mazeland
2013-08-05 06:04:08 +02:00
parent 0af4375e7c
commit 622e388a6a

View File

@@ -83,10 +83,18 @@ class LanguageNameSearch {
// 224 is the lowest non-overlong-encoded codepoint. // 224 is the lowest non-overlong-encoded codepoint.
$lookingFor = ( $thisValue < 224 ) ? 2 : 3; $lookingFor = ( $thisValue < 224 ) ? 2 : 3;
} }
$values[] = $thisValue; $values[] = $thisValue;
if ( count( $values ) === $lookingFor ) { if ( count( $values ) === $lookingFor ) {
// Refer http://en.wikipedia.org/wiki/UTF-8#Description // Refer http://en.wikipedia.org/wiki/UTF-8#Description
$number = ( $lookingFor === 3 ) ? ( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ) : ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 ); if ( $lookingFor === 3 ) {
$number = ( $values[0] % 16 ) * 4096;
$number += ( $values[1] % 64 ) * 64;
$number += $values[2] % 64;
} else {
$number = ( $values[0] % 32 ) * 64;
$number += $values[1] % 64;
}
return $number; return $number;
} }