summaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorandreast <andreast@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-31 09:50:40 +0000
committerandreast <andreast@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-31 09:50:40 +0000
commite517ae8d78fc3b065c5c0935a3042b26ec6f05aa (patch)
tree932905a0edb65eb0f9f8b0778733087b34517924 /libjava/java
parent2b59cb0507a0cd617d4b6fda5d0ba9673daf1fb2 (diff)
downloadgcc-e517ae8d78fc3b065c5c0935a3042b26ec6f05aa.tar.gz
2004-08-31 Tom Tromey <tromey@redhat.com>
* java/text/AttributedString.java (AttributedString): Use ArrayList to build array of attribute ranges. Don't use `attribs' before it is set. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86825 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/text/AttributedString.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/libjava/java/text/AttributedString.java b/libjava/java/text/AttributedString.java
index 8304cedf7bc..41512dc6c5e 100644
--- a/libjava/java/text/AttributedString.java
+++ b/libjava/java/text/AttributedString.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package java.text;
import java.util.Arrays;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
@@ -224,6 +225,7 @@ AttributedString(AttributedCharacterIterator aci, int begin_index,
// Loop through and extract the attributes
char c = aci.setIndex(begin_index);
+ ArrayList accum = new ArrayList();
do
{
sb.append(c);
@@ -272,17 +274,17 @@ AttributedString(AttributedCharacterIterator aci, int begin_index,
Map new_map = new Hashtable();
new_map.put(attrib, attrib_obj);
- // Add it to the attribute list. Yes this is a bad way to do things.
- AttributeRange[] new_list = new AttributeRange[attribs.length + 1];
- System.arraycopy(attribs, 0, new_list, 0, attribs.length);
- attribs = new_list;
- attribs[attribs.length - 1] = new AttributeRange(new_map, rs, rl);
+ // Add it to the attribute list.
+ accum.add(new AttributeRange(new_map, rs, rl));
}
c = aci.next();
}
while(c != CharacterIterator.DONE);
+ attribs = new AttributeRange[accum.size()];
+ attribs = (AttributeRange[]) accum.toArray(attribs);
+
sci = new StringCharacterIterator(sb.toString());
}