Package dev.gmitch215.bytebox.text


package dev.gmitch215.bytebox.text
What makes String.format cost what it costs here, which nothing in a project has to name.

String.format and printf both go through java.util.Formatter, and the class library's version reaches a decimal formatter, a currency table and the locale data behind them from the single method that dispatches on the conversion character. Because that is one method, every conversion is reachable from every use, so a format string of "%s and %d" pays for all of it: 85 KB of WebAssembly after compression, against a hello world of 7 KB. The digits come from the platform instead, and Locale - 0.9 KB on its own - is what remains.

Formatter records what that costs in behaviour: %t and %a throw and name their replacements, a precision above 100 pads with zeros, and grouping is every three digits.

Since:
1.0.0
  • Class
    Description
    %t and %T for String.format, which a project switches on with classlib { dateFormat = true }.
    The class library's DoubleAnalyzer (TeaVM 0.15.0, org.teavm.classlib.impl.text), with its choice of digits replaced.
     
    Where DecimalFormat gets the double for a number it read, in place of the class library's.
    The class library's FloatAnalyzer (TeaVM 0.15.0, org.teavm.classlib.impl.text), with its digits worked out by Exact.
     
    A type that formats itself, standing in for java.util.Formattable.
    The flags a Formattable is told about, standing in for java.util.FormattableFlags.
    A formatter, standing in for java.util.Formatter.
    A format string the formatter will not accept, standing in for java.util.IllegalFormatException.
    A specifier with no argument to fill it, standing in for java.util.MissingFormatArgumentException.
    Points Double.parseDouble and Float.parseFloat at Parse.
    java.util.StringJoiner, which the class library does not carry.
    Points java.util.Formatter and what it needs at the ones in this package.