summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2009-09-21 14:08:38 -0700
committerElliott Hughes <enh@google.com>2009-09-21 14:08:38 -0700
commita564e32377d6b926988fe67559f7550233a9845b (patch)
treebc3dd695cacf1594ca4dc7d53b96c28c55fd8c81
parent06d80c8776377e6c22c21e892abfb2ed3c48ebf7 (diff)
downloadlibcore-a564e32377d6b926988fe67559f7550233a9845b.zip
libcore-a564e32377d6b926988fe67559f7550233a9845b.tar.gz
libcore-a564e32377d6b926988fe67559f7550233a9845b.tar.bz2
Consistently use Formatter's cached NumberFormat.
%f is a lot more expensive than it should be because we're not using the cached NumberFormat (as we are for %d). Running the microbenchmark I added to the bug (times in ms, on a Cortex A8): old new new Formatter %f 1732 811 String.format %d 635 651 String.format %f 1752 900 reuse Formatter %f 1521 188 Double.toString + 149 148 Double.toString append 33 33 StringBuilder.append 143 139 Bug: 1476
-rw-r--r--luni/src/main/java/java/util/Formatter.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/luni/src/main/java/java/util/Formatter.java b/luni/src/main/java/java/util/Formatter.java
index d1dd417..3196f0e 100644
--- a/luni/src/main/java/java/util/Formatter.java
+++ b/luni/src/main/java/java/util/Formatter.java
@@ -1896,7 +1896,7 @@ public final class Formatter implements Closeable, Flushable {
}
// output result
FloatUtil floatUtil = new FloatUtil(result, formatToken,
- (DecimalFormat) NumberFormat.getInstance(locale), arg);
+ (DecimalFormat) getNumberFormat(), arg);
floatUtil.transform(formatToken, result);
formatToken.setPrecision(FormatToken.UNSET);