$phpUpper = $wgContLang->ucfirst( $char );
$jsUpper = $jsUpperChars[$i];
if ( $jsUpper !== $phpUpper ) {
- $data[$char] = $phpUpper;
+ if ( $char === $phpUpper ) {
+ // Optimisation: Use the empty string to signal "leave character unchanged".
+ // Reduces the transfer size by ~50%. Reduces browser memory cost as well.
+ $data[$char] = '';
+ } else {
+ $data[$char] = $phpUpper;
+ }
}
}
) . "\n";
$outputPath = '/resources/src/mediawiki.Title/phpCharToUpper.json';
$file = fopen( $IP . $outputPath, 'w' );
+ if ( !$file ) {
+ $this->fatalError( "Unable to write file \"$IP$outputPath\"" );
+ }
fwrite( $file, $mappingJson );
$this->output( count( $data ) . " differences found.\n" );