aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>1999-05-07 17:39:52 +0000
committerTom Tromey <tromey@gcc.gnu.org>1999-05-07 17:39:52 +0000
commitc59c5e9a6508d3a72fe058126482083ad2e5ceeb (patch)
treefa48d4253f7d39a998ed21736d3486657e6b33ae
parenta06fcbd4642aa771f89763ee68de272fe0b1003e (diff)
downloadgcc-c59c5e9a6508d3a72fe058126482083ad2e5ceeb.zip
gcc-c59c5e9a6508d3a72fe058126482083ad2e5ceeb.tar.gz
gcc-c59c5e9a6508d3a72fe058126482083ad2e5ceeb.tar.bz2
* java/lang/natCharacter.cc (isLowerCase): Use a binary search.
From-SVN: r26829
-rw-r--r--libjava/ChangeLog2
-rw-r--r--libjava/java/lang/natCharacter.cc21
2 files changed, 20 insertions, 3 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 09740cd..4066dae 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,7 @@
1999-05-07 Tom Tromey <tromey@cygnus.com>
+ * java/lang/natCharacter.cc (isLowerCase): Use a binary search.
+
* libtool-version: New file.
* Makefile.in: Rebuilt.
* Makefile.am (libgcj_la_LDFLAGS): Use -version-info, not
diff --git a/libjava/java/lang/natCharacter.cc b/libjava/java/lang/natCharacter.cc
index 36cf570..fa312d1 100644
--- a/libjava/java/lang/natCharacter.cc
+++ b/libjava/java/lang/natCharacter.cc
@@ -152,12 +152,27 @@ java::lang::Character::isLowerCase (jchar ch)
if (table_search (lower_case_table, asize (lower_case_table), ch) != -1)
return true;
- // FIXME: use a binary search.
- for (unsigned int i = 0; i < asize (lower_anomalous_table); ++i)
+ int low, high, i, old;
+
+ low = 0;
+ high = asize (lower_anomalous_table);
+ i = high / 2;
+
+ while (true)
{
- if (lower_anomalous_table[i] == ch)
+ if (ch < lower_anomalous_table[i])
+ high = i;
+ else if (ch > lower_anomalous_table[i])
+ low = i;
+ else
return true;
+
+ old = i;
+ i = (high + low) / 2;
+ if (i == old)
+ break;
}
+
return false;
}