@@ -120,7 +120,7 @@ public class GenerateCurrencyData {
120120
121121 private static final int maxOtherCurrencies = 128 ;
122122 private static int otherCurrenciesCount = 0 ;
123- private static StringBuffer otherCurrencies = new StringBuffer () ;
123+ private static String [] otherCurrencies = new String [ maxOtherCurrencies ] ;
124124 private static int [] otherCurrenciesDefaultFractionDigits = new int [maxOtherCurrencies ];
125125 private static int [] otherCurrenciesNumericCode = new int [maxOtherCurrencies ];
126126
@@ -323,10 +323,7 @@ private static void buildOtherTables() {
323323 if (otherCurrenciesCount == maxOtherCurrencies ) {
324324 throw new RuntimeException ("too many other currencies" );
325325 }
326- if (otherCurrencies .length () > 0 ) {
327- otherCurrencies .append ('-' );
328- }
329- otherCurrencies .append (currencyCode );
326+ otherCurrencies [otherCurrenciesCount ] = currencyCode ;
330327 otherCurrenciesDefaultFractionDigits [otherCurrenciesCount ] = getDefaultFractionDigits (currencyCode );
331328 otherCurrenciesNumericCode [otherCurrenciesCount ] = getNumericCode (currencyCode );
332329 otherCurrenciesCount ++;
@@ -355,35 +352,41 @@ private static void writeOutput() throws IOException {
355352 out .writeInt (Integer .parseInt (dataVersion ));
356353 writeIntArray (mainTable , mainTable .length );
357354 out .writeInt (specialCaseCount );
358- writeLongArray (specialCaseCutOverTimes , specialCaseCount );
359- writeStringArray (specialCaseOldCurrencies , specialCaseCount );
360- writeStringArray (specialCaseNewCurrencies , specialCaseCount );
361- writeIntArray (specialCaseOldCurrenciesDefaultFractionDigits , specialCaseCount );
362- writeIntArray (specialCaseNewCurrenciesDefaultFractionDigits , specialCaseCount );
363- writeIntArray (specialCaseOldCurrenciesNumericCode , specialCaseCount );
364- writeIntArray (specialCaseNewCurrenciesNumericCode , specialCaseCount );
355+ writeSpecialCaseEntries ();
365356 out .writeInt (otherCurrenciesCount );
366- out .writeUTF (otherCurrencies .toString ());
367- writeIntArray (otherCurrenciesDefaultFractionDigits , otherCurrenciesCount );
368- writeIntArray (otherCurrenciesNumericCode , otherCurrenciesCount );
357+ writeOtherCurrencies ();
369358 }
370359
371360 private static void writeIntArray (int [] ia , int count ) throws IOException {
372- for (int i = 0 ; i < count ; i ++) {
361+ for (int i = 0 ; i < count ; i ++) {
373362 out .writeInt (ia [i ]);
374363 }
375364 }
376365
377- private static void writeLongArray (long [] la , int count ) throws IOException {
378- for (int i = 0 ; i < count ; i ++) {
379- out .writeLong (la [i ]);
366+ private static void writeSpecialCaseEntries () throws IOException {
367+ for (int index = 0 ; index < specialCaseCount ; index ++) {
368+ out .writeLong (specialCaseCutOverTimes [index ]);
369+ String str = (specialCaseOldCurrencies [index ] != null )
370+ ? specialCaseOldCurrencies [index ] : "" ;
371+ out .writeUTF (str );
372+ str = (specialCaseNewCurrencies [index ] != null )
373+ ? specialCaseNewCurrencies [index ] : "" ;
374+ out .writeUTF (str );
375+ out .writeInt (specialCaseOldCurrenciesDefaultFractionDigits [index ]);
376+ out .writeInt (specialCaseNewCurrenciesDefaultFractionDigits [index ]);
377+ out .writeInt (specialCaseOldCurrenciesNumericCode [index ]);
378+ out .writeInt (specialCaseNewCurrenciesNumericCode [index ]);
380379 }
381380 }
382381
383- private static void writeStringArray (String [] sa , int count ) throws IOException {
384- for (int i = 0 ; i < count ; i ++) {
385- String str = (sa [i ] != null ) ? sa [i ] : "" ;
382+ private static void writeOtherCurrencies () throws IOException {
383+ for (int index = 0 ; index < otherCurrenciesCount ; index ++) {
384+ String str = (otherCurrencies [index ] != null )
385+ ? otherCurrencies [index ] : "" ;
386386 out .writeUTF (str );
387+ out .writeInt (otherCurrenciesDefaultFractionDigits [index ]);
388+ out .writeInt (otherCurrenciesNumericCode [index ]);
387389 }
388390 }
391+
389392}
0 commit comments