mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-16 10:17:23 +00:00
ICU-8268 Inefficient use of Map.keySet. Use entrySet instead.
X-SVN-Rev: 30721
This commit is contained in:
parent
b8f1bb9223
commit
55e9ba2738
8 changed files with 55 additions and 39 deletions
|
@ -18,6 +18,7 @@ import java.util.Comparator;
|
|||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -204,13 +205,16 @@ public class UnicodeRegex implements Cloneable, Freezable<UnicodeRegex>, StringT
|
|||
// brute force replacement; do twice to allow for different order
|
||||
// later on can optimize
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (String variable : variables.keySet()) {
|
||||
String definition = variables.get(variable);
|
||||
for (String variable2 : variables.keySet()) {
|
||||
for (Entry<String, String> entry : variables.entrySet()) {
|
||||
String variable = entry.getKey(),
|
||||
definition = entry.getValue();
|
||||
|
||||
for (Entry<String, String> entry2 : variables.entrySet()) {
|
||||
String variable2 = entry2.getKey(),
|
||||
definition2 = entry2.getValue();
|
||||
if (variable.equals(variable2)) {
|
||||
continue;
|
||||
}
|
||||
String definition2 = variables.get(variable2);
|
||||
String altered2 = definition2.replace(variable, definition);
|
||||
if (!altered2.equals(definition2)) {
|
||||
unused.remove(variable);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2008-2010, International Business Machines Corporation and *
|
||||
* Copyright (C) 2008-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -11,6 +11,7 @@ import java.io.Serializable;
|
|||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
import com.ibm.icu.impl.ICUCache;
|
||||
|
@ -760,8 +761,9 @@ public class DateIntervalInfo implements Cloneable, Freezable<DateIntervalInfo>,
|
|||
for (String skeleton : fIntervalPatterns.keySet()) {
|
||||
Map<String, PatternInfo> patternsOfOneSkeleton = fIntervalPatterns.get(skeleton);
|
||||
Map<String, PatternInfo> oneSetPtn = new HashMap<String, PatternInfo>();
|
||||
for (String calField : patternsOfOneSkeleton.keySet()) {
|
||||
PatternInfo value = patternsOfOneSkeleton.get(calField);
|
||||
for (Entry<String, PatternInfo> calEntry : patternsOfOneSkeleton.entrySet()) {
|
||||
String calField = calEntry.getKey();
|
||||
PatternInfo value = calEntry.getValue();
|
||||
oneSetPtn.put(calField, value);
|
||||
}
|
||||
other.fIntervalPatterns.put(skeleton, oneSetPtn);
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.icu.impl.PatternProps;
|
||||
|
@ -981,8 +982,8 @@ public class PluralRules implements Serializable {
|
|||
}
|
||||
|
||||
// Make lists immutable so we can return them directly
|
||||
for (String key : sampleMap.keySet()) {
|
||||
sampleMap.put(key, Collections.unmodifiableList(sampleMap.get(key)));
|
||||
for (Entry<String, List<Double>> entry : sampleMap.entrySet()) {
|
||||
sampleMap.put(entry.getKey(), Collections.unmodifiableList(entry.getValue()));
|
||||
}
|
||||
_keySamplesMap = sampleMap;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
**************************************************************************
|
||||
* Copyright (C) 2008-2011, Google, International Business Machines
|
||||
* Corporationand others. All Rights Reserved.
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
@ -11,6 +11,7 @@ import java.text.ParsePosition;
|
|||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
@ -193,10 +194,8 @@ public class TimeUnitFormat extends MeasureFormat {
|
|||
if (isReady == false) {
|
||||
return this;
|
||||
}
|
||||
for (TimeUnit timeUnit : timeUnitToCountToPatterns.keySet()) {
|
||||
Map<String, Object[]> countToPattern = timeUnitToCountToPatterns.get(timeUnit);
|
||||
for (String count : countToPattern.keySet()) {
|
||||
Object[] pair = countToPattern.get(count);
|
||||
for (Map<String, Object[]> countToPattern : timeUnitToCountToPatterns.values()) {
|
||||
for (Object[] pair : countToPattern.values()) {
|
||||
MessageFormat pattern = (MessageFormat)pair[FULL_NAME];
|
||||
pattern.setFormatByArgumentIndex(0, format);
|
||||
pattern = (MessageFormat)pair[ABBREVIATED_NAME];
|
||||
|
@ -249,9 +248,10 @@ public class TimeUnitFormat extends MeasureFormat {
|
|||
// and looking for the longest match.
|
||||
for (TimeUnit timeUnit : timeUnitToCountToPatterns.keySet()) {
|
||||
Map<String, Object[]> countToPattern = timeUnitToCountToPatterns.get(timeUnit);
|
||||
for (String count : countToPattern.keySet()) {
|
||||
for (Entry<String, Object[]> patternEntry : countToPattern.entrySet()) {
|
||||
String count = patternEntry.getKey();
|
||||
for (int styl = FULL_NAME; styl < TOTAL_STYLES; ++styl) {
|
||||
MessageFormat pattern = (MessageFormat)(countToPattern.get(count))[styl];
|
||||
MessageFormat pattern = (MessageFormat)(patternEntry.getValue())[styl];
|
||||
pos.setErrorIndex(-1);
|
||||
pos.setIndex(oldPos);
|
||||
// see if we can parse
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
****************************************************************************************
|
||||
* Copyright (C) 2010, Google, Inc.; International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
****************************************************************************************
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010-2011, Google, Inc.; International Business Machines *
|
||||
* Corporation and others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.util;
|
||||
|
@ -13,6 +13,7 @@ import java.util.Iterator;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -241,8 +242,9 @@ public class LocalePriorityList implements Iterable<ULocale> {
|
|||
// We now have a bunch of items sorted by weight, then chronologically.
|
||||
// We can now create a list in the right order
|
||||
final Map<ULocale, Double> temp = new LinkedHashMap<ULocale, Double>();
|
||||
for (final Double weight : doubleCheck.keySet()) {
|
||||
for (final ULocale lang : doubleCheck.get(weight)) {
|
||||
for (Entry<Double, Set<ULocale>> langEntry : doubleCheck.entrySet()) {
|
||||
final Double weight = langEntry.getKey();
|
||||
for (final ULocale lang : langEntry.getValue()) {
|
||||
temp.put(lang, preserveWeights ? weight : D1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2008, International Business Machines Corporation and *
|
||||
* Copyright (C) 2008-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -16,6 +16,7 @@ import java.text.ParsePosition;
|
|||
import java.util.Currency;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.icu.text.DecimalFormat;
|
||||
|
@ -108,10 +109,11 @@ public class DecimalFormatICU extends java.text.DecimalFormat {
|
|||
int end = aci.getRunLimit();
|
||||
Map<AttributedCharacterIterator.Attribute,Object> jdkAttributes =
|
||||
new HashMap<AttributedCharacterIterator.Attribute,Object>();
|
||||
Set<AttributedCharacterIterator.Attribute> keys = attributes.keySet();
|
||||
for (AttributedCharacterIterator.Attribute key : keys) {
|
||||
for (Entry<AttributedCharacterIterator.Attribute, Object> entry
|
||||
: attributes.entrySet()) {
|
||||
AttributedCharacterIterator.Attribute key = entry.getKey();
|
||||
AttributedCharacterIterator.Attribute jdkKey = mapAttribute(key);
|
||||
Object jdkVal = attributes.get(key);
|
||||
Object jdkVal = entry.getValue();
|
||||
if (jdkVal instanceof AttributedCharacterIterator.Attribute) {
|
||||
jdkVal = mapAttribute((AttributedCharacterIterator.Attribute)jdkVal);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2008, International Business Machines Corporation and *
|
||||
* Copyright (C) 2008-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -18,6 +18,7 @@ import java.util.Date;
|
|||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
|
@ -105,10 +106,11 @@ public class SimpleDateFormatICU extends java.text.SimpleDateFormat {
|
|||
int end = aci.getRunLimit();
|
||||
Map<AttributedCharacterIterator.Attribute,Object> jdkAttributes =
|
||||
new HashMap<AttributedCharacterIterator.Attribute,Object>();
|
||||
Set<AttributedCharacterIterator.Attribute> keys = attributes.keySet();
|
||||
for (AttributedCharacterIterator.Attribute key : keys) {
|
||||
for (Entry<AttributedCharacterIterator.Attribute, Object> entry
|
||||
: attributes.entrySet()) {
|
||||
AttributedCharacterIterator.Attribute key = entry.getKey();
|
||||
AttributedCharacterIterator.Attribute jdkKey = mapAttribute(key);
|
||||
Object jdkVal = attributes.get(key);
|
||||
Object jdkVal = entry.getValue();
|
||||
if (jdkVal instanceof AttributedCharacterIterator.Attribute) {
|
||||
jdkVal = mapAttribute((AttributedCharacterIterator.Attribute)jdkVal);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2009-2010, Google, International Business Machines
|
||||
* Copyright (c) 2009-2011, Google, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Author: Mark Davis
|
||||
|
@ -25,6 +25,7 @@ import java.util.Comparator;
|
|||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
@ -236,8 +237,9 @@ public class CheckSystemFonts {
|
|||
System.out.println("\n***RAW COVERAGE (bridging unassigned)\n");
|
||||
PrintWriter out = BagFormatter.openUTF8Writer(outputDirectoryName, "raw_coverage.txt");
|
||||
|
||||
for (UnicodeSet s : data.keySet()) {
|
||||
Set<String> nameSet = data.get(s);
|
||||
for (Entry<UnicodeSet, Set<String>> entry : data.entrySet()) {
|
||||
UnicodeSet s = entry.getKey();
|
||||
Set<String> nameSet = entry.getValue();
|
||||
String name = nameSet.iterator().next();
|
||||
UnicodeSet bridged = new UnicodeSet(s).addBridges(DONT_CARE);
|
||||
out.println(name + "\t" + s.size() + "\t" + bridged);
|
||||
|
@ -253,8 +255,9 @@ public class CheckSystemFonts {
|
|||
|
||||
Map<String,Set<String>> nameToSingleton = new HashMap<String,Set<String>>();
|
||||
|
||||
for (UnicodeSet s : data.keySet()) {
|
||||
Set<String> nameSet = data.get(s);
|
||||
for (Entry<UnicodeSet, Set<String>> entry : data.entrySet()) {
|
||||
UnicodeSet s = entry.getKey();
|
||||
Set<String> nameSet = entry.getValue();
|
||||
String name = nameSet.iterator().next();
|
||||
//System.out.println(s);
|
||||
Set<String> temp2 = nameToSingleton.get(name);
|
||||
|
@ -371,8 +374,9 @@ public class CheckSystemFonts {
|
|||
}
|
||||
fontMap.put(name,font);
|
||||
}
|
||||
for (String name : fontMap.keySet()) {
|
||||
Font font = fontMap.get(name);
|
||||
for (Entry<String, Font> entry : fontMap.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
Font font = entry.getValue();
|
||||
System.out.println(name);
|
||||
UnicodeSet coverage = getCoverage(font);
|
||||
Set<String> sameFonts = data.get(coverage);
|
||||
|
@ -555,8 +559,7 @@ public class CheckSystemFonts {
|
|||
//System.out.println(result.size() + "\t" + result);
|
||||
for (Rectangle2D bounds : boundsToData.keySet()) {
|
||||
Map<Shape, UnicodeSet> map = boundsToData.get(bounds);
|
||||
for (Shape shape : map.keySet()) {
|
||||
UnicodeSet set = map.get(shape);
|
||||
for (UnicodeSet set : map.values()) {
|
||||
set.removeAll(CONTROLS);
|
||||
if (set.size() != 1) {
|
||||
//System.out.println(set.toPattern(false));
|
||||
|
|
Loading…
Add table
Reference in a new issue