EditableProperties optimizations.
Implement get() directly rather than relying on an iterator over the entry set.
Use StringBuilder rather than StringBuffer.
1.1 --- a/openide.util/src/org/openide/util/EditableProperties.java Fri Aug 07 13:08:58 2009 -0400
1.2 +++ b/openide.util/src/org/openide/util/EditableProperties.java Fri Aug 07 16:05:37 2009 -0400
1.3 @@ -216,6 +216,19 @@
1.4 }
1.5
1.6 @Override
1.7 + public String get(Object key) {
1.8 + if (!(key instanceof String)) {
1.9 + return null;
1.10 + }
1.11 + for (Item item : items) {
1.12 + if (key.equals(item.getKey())) {
1.13 + return item.getValue();
1.14 + }
1.15 + }
1.16 + return null;
1.17 + }
1.18 +
1.19 + @Override
1.20 public String put(String key, String value) {
1.21 Parameters.notNull("key", key);
1.22 Parameters.notNull(key, value);
1.23 @@ -518,7 +531,7 @@
1.24 }
1.25
1.26 public void setValue(List<String> value) {
1.27 - StringBuffer val = new StringBuffer();
1.28 + StringBuilder val = new StringBuilder();
1.29 List<String> l = new ArrayList<String>();
1.30 if (!value.isEmpty()) {
1.31 l.add(encode(key, true) + "=\\"); // NOI18N
1.32 @@ -610,7 +623,7 @@
1.33 private static String decode(String input) {
1.34 char ch;
1.35 int len = input.length();
1.36 - StringBuffer output = new StringBuffer(len);
1.37 + StringBuilder output = new StringBuilder(len);
1.38 for (int x=0; x<len; x++) {
1.39 ch = input.charAt(x);
1.40 if (ch != '\\') {
1.41 @@ -651,7 +664,7 @@
1.42
1.43 private static String encode(String input, boolean escapeSpace) {
1.44 int len = input.length();
1.45 - StringBuffer output = new StringBuffer(len*2);
1.46 + StringBuilder output = new StringBuilder(len*2);
1.47
1.48 for(int x=0; x<len; x++) {
1.49 char ch = input.charAt(x);
1.50 @@ -696,7 +709,7 @@
1.51 private static String decodeUnicode(String input) {
1.52 char ch;
1.53 int len = input.length();
1.54 - StringBuffer output = new StringBuffer(len);
1.55 + StringBuilder output = new StringBuilder(len);
1.56 for (int x = 0; x < len; x++) {
1.57 ch = input.charAt(x);
1.58 if (ch != '\\') {
1.59 @@ -733,7 +746,7 @@
1.60
1.61 private static String encodeUnicode(String input) {
1.62 int len = input.length();
1.63 - StringBuffer output = new StringBuffer(len * 2);
1.64 + StringBuilder output = new StringBuilder(len * 2);
1.65 for (int x = 0; x < len; x++) {
1.66 char ch = input.charAt(x);
1.67 if ((ch < 0x0020) || (ch > 0x007e)) {