Class SmallIntStrings
java.lang.Object
org.ek9lang.compiler.support.SmallIntStrings
- All Implemented Interfaces:
IntFunction<String>
THE shared cache of small non-negative int-to-String conversions — use this instead of
String.valueOf(int) / Integer.toString(int) when the result is squirrelled or
otherwise retained per symbol.
String.valueOf(n) allocates a fresh ~48 B String on every call, so stamping a metric
(COMPLEXITY, COGNITIVE_COMPLEXITY, ...) on tens of thousands of symbols leaves tens of thousands of
distinct String objects even though the underlying values repeat heavily (a handful of small
integers). Returning a shared, pre-computed String for 0..1024-1 collapses those to one
object per distinct value — retained-heap saving, not just churn.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
SmallIntStrings
public SmallIntStrings()
-
-
Method Details
-
apply
The decimal String forvalue, shared for 0..1023 and freshly computed (rare) beyond that.- Specified by:
applyin interfaceIntFunction<String>
-