summaryrefslogtreecommitdiffstats
path: root/libjava
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-31 01:03:21 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-31 01:03:21 +0000
commitf9c2c15ec4c44b2813305c66f41cf23a67959e39 (patch)
tree614aa9cc5d316d4c5d330c01ada4e1de16a5607d /libjava
parent8afa16d4dda66b0d77bf48ae298750ffe47b3277 (diff)
downloadppe42-gcc-f9c2c15ec4c44b2813305c66f41cf23a67959e39.tar.gz
ppe42-gcc-f9c2c15ec4c44b2813305c66f41cf23a67959e39.zip
* java/lang/String.java (data, boffset, count): Documented.
(String(byte[],String)): Reformatted. (String(byte[])): Likewise. (lastIndexOf(int)): Likewise. (lastIndexOf(String)): Likewise. (substring(int)): Renamed argument to match Classpath. (String(StringBuffer)): Don't share buffer if it is nearly empty. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65070 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog8
-rw-r--r--libjava/java/lang/String.java39
2 files changed, 38 insertions, 9 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index e74022bbbde..84b6b6c270d 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,13 @@
2003-03-30 Tom Tromey <tromey@redhat.com>
+ * java/lang/String.java (data, boffset, count): Documented.
+ (String(byte[],String)): Reformatted.
+ (String(byte[])): Likewise.
+ (lastIndexOf(int)): Likewise.
+ (lastIndexOf(String)): Likewise.
+ (substring(int)): Renamed argument to match Classpath.
+ (String(StringBuffer)): Don't share buffer if it is nearly empty.
+
* java/lang/String.java: Miscellaneous minor formatting changes
to match Classpath more closely.
diff --git a/libjava/java/lang/String.java b/libjava/java/lang/String.java
index 5011c357a71..fe00b9100cc 100644
--- a/libjava/java/lang/String.java
+++ b/libjava/java/lang/String.java
@@ -84,8 +84,26 @@ public final class String implements Serializable, Comparable, CharSequence
*/
private static final long serialVersionUID = -6849794470754667710L;
+ /**
+ * This is the object that holds the characters that make up the
+ * String. It might be a char[], or it could be String. It could
+ * even be `this'. The actual characters can't be located using
+ * pure Java code.
+ * @see #boffset
+ */
private Object data;
- private int boffset; // Note this is a byte offset - don't use in Java code!
+
+ /**
+ * This is a <emph>byte</emph> offset of the actual characters from
+ * the start of the character-holding object. Don't use this field
+ * in Java code.
+ */
+ private int boffset;
+
+ /**
+ * Holds the number of characters in value. Package visible for use
+ * by trusted code.
+ */
int count;
/**
@@ -298,7 +316,7 @@ public final class String implements Serializable, Comparable, CharSequence
public String(byte[] data, String encoding)
throws UnsupportedEncodingException
{
- this (data, 0, data.length, encoding);
+ this(data, 0, data.length, encoding);
}
/**
@@ -357,7 +375,7 @@ public final class String implements Serializable, Comparable, CharSequence
*/
public String(byte[] data)
{
- this (data, 0, data.length);
+ this(data, 0, data.length);
}
/**
@@ -371,8 +389,11 @@ public final class String implements Serializable, Comparable, CharSequence
{
synchronized (buffer)
{
- buffer.shared = true;
- init (buffer.value, 0, buffer.count, true);
+ // Share unless buffer is 3/4 empty.
+ boolean should_copy = ((buffer.count << 2) < buffer.value.length);
+ if (! should_copy)
+ buffer.shared = true;
+ init (buffer.value, 0, buffer.count, ! should_copy);
}
}
@@ -721,7 +742,7 @@ public final class String implements Serializable, Comparable, CharSequence
*/
public int lastIndexOf(int ch)
{
- return lastIndexOf (ch, count - 1);
+ return lastIndexOf(ch, count - 1);
}
/**
@@ -770,7 +791,7 @@ public final class String implements Serializable, Comparable, CharSequence
*/
public int lastIndexOf(String str)
{
- return lastIndexOf (str, count - str.count);
+ return lastIndexOf(str, count - str.count);
}
/**
@@ -806,9 +827,9 @@ public final class String implements Serializable, Comparable, CharSequence
* @throws IndexOutOfBoundsException if begin &lt; 0 || begin &gt; length()
* (while unspecified, this is a StringIndexOutOfBoundsException)
*/
- public String substring(int beginIndex)
+ public String substring(int begin)
{
- return substring (beginIndex, count);
+ return substring(begin, count);
}
/**
OpenPOWER on IntegriCloud