summaryrefslogtreecommitdiffstats
path: root/benchmarks
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2013-10-30 17:27:26 +0000
committerNarayan Kamath <narayan@google.com>2013-10-30 17:27:26 +0000
commit71852e47df6b12fde7103bc559dd2d756eb8ddc4 (patch)
treecfec3a02b88cc5f61e5addb2915abcd2ee35e1b0 /benchmarks
parent676ce12e65abd5a9b5aae9662e4a78f6b0cb1487 (diff)
downloadlibcore-71852e47df6b12fde7103bc559dd2d756eb8ddc4.zip
libcore-71852e47df6b12fde7103bc559dd2d756eb8ddc4.tar.gz
libcore-71852e47df6b12fde7103bc559dd2d756eb8ddc4.tar.bz2
Remove unused code from CharsetBenchmark.
This in preparation for removing UnsafeBytesequence. Split into a separate change so that it's easier to resurrect if required. Change-Id: I24b8cd6a56a37d4efc23cfea0b59adc0f065f5a2
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/src/benchmarks/regression/CharsetBenchmark.java59
1 files changed, 0 insertions, 59 deletions
diff --git a/benchmarks/src/benchmarks/regression/CharsetBenchmark.java b/benchmarks/src/benchmarks/regression/CharsetBenchmark.java
index 6ecada7..21b9966 100644
--- a/benchmarks/src/benchmarks/regression/CharsetBenchmark.java
+++ b/benchmarks/src/benchmarks/regression/CharsetBenchmark.java
@@ -68,65 +68,6 @@ public class CharsetBenchmark extends SimpleBenchmark {
}
}
- // FIXME: benchmark this pure-java implementation for US-ASCII and ISO-8859-1 too!
-
- /**
- * Translates the given characters to US-ASCII or ISO-8859-1 bytes, using the fact that
- * Unicode code points between U+0000 and U+007f inclusive are identical to US-ASCII, while
- * U+0000 to U+00ff inclusive are identical to ISO-8859-1.
- */
- private static byte[] toDirectMappedBytes(char[] chars, int offset, int length, int maxValidChar) {
- byte[] result = new byte[length];
- int o = offset;
- for (int i = 0; i < length; ++i) {
- int ch = chars[o++];
- result[i] = (byte) ((ch <= maxValidChar) ? ch : '?');
- }
- return result;
- }
-
- private static byte[] toUtf8Bytes(char[] chars, int offset, int length) {
- UnsafeByteSequence result = new UnsafeByteSequence(length);
- toUtf8Bytes(chars, offset, length, result);
- return result.toByteArray();
- }
-
- private static void toUtf8Bytes(char[] chars, int offset, int length, UnsafeByteSequence out) {
- final int end = offset + length;
- for (int i = offset; i < end; ++i) {
- int ch = chars[i];
- if (ch < 0x80) {
- // One byte.
- out.write(ch);
- } else if (ch < 0x800) {
- // Two bytes.
- out.write((ch >> 6) | 0xc0);
- out.write((ch & 0x3f) | 0x80);
- } else if (ch >= Character.MIN_SURROGATE && ch <= Character.MAX_SURROGATE) {
- // A supplementary character.
- char high = (char) ch;
- char low = (i + 1 != end) ? chars[i + 1] : '\u0000';
- if (!Character.isSurrogatePair(high, low)) {
- out.write('?');
- continue;
- }
- // Now we know we have a *valid* surrogate pair, we can consume the low surrogate.
- ++i;
- ch = Character.toCodePoint(high, low);
- // Four bytes.
- out.write((ch >> 18) | 0xf0);
- out.write(((ch >> 12) & 0x3f) | 0x80);
- out.write(((ch >> 6) & 0x3f) | 0x80);
- out.write((ch & 0x3f) | 0x80);
- } else {
- // Three bytes.
- out.write((ch >> 12) | 0xe0);
- out.write(((ch >> 6) & 0x3f) | 0x80);
- out.write((ch & 0x3f) | 0x80);
- }
- }
- }
-
private static String makeString(int length) {
StringBuilder result = new StringBuilder(length);
for (int i = 0; i < length; ++i) {