With large data sets, the Path object created was sufficiently large as to cause an OutOfMemory error. This is resolved by only pathing a limited number of points on the chart at a time, then clearing the path and resuming. Stress testing with 1500 entries.
With large data sets, the Path object created was sufficiently large as to cause an OutOfMemory error. This is resolved by only pathing a limited number of points on the chart at a time, then clearing the path and resuming. Stress testing with 1500 entries.
Created unit tests for the FormattedStringCache classes. Also, took this opportunity to create a FormattedStringCache.Generic<K,V> static class to take over what was previously simply FormattedStringCache. Verified that all unit tests still pass.
Many short-lived ArrayLists were created in various methods, which could easily have been extracted to field level variable. This has been done, and the arrays cleared before use.
paint.getFontMetrics() has a hidden allocation. paint.getFontMetrics(fontMetrics) is used internally inside of Paint, so caching and holding onto a metrics buffer helps reduce allocations.
getXBounds creates a disposable XBounds instance on every call. Cache it and update the values with a set method. This means XBounds values are now mutable.
Buffering temporary Rect and RectF instances. Created methods to modify RectF instances as performance alternatives to methods that create disposable RectF instances.
ValueFormatter objects now rely on a FormattedStringCache to return already-formatted Strings. We might want to create primitive-enabled versions since all our values to format are float or double primitives, and the keys are also all primitives. This will eliminate auto-boxing penalties.
foreach(:) arrays on Android carry the cost that each iteration creates an implicit instantiation. for(;;) arrays are uglier but guarantee that no unwanted allocations occur while iterating.
Created buffers for short lived Matrix and Path objects, resetting them instead of instantiating new ones. Also created some matrix transform methods that accept output Matrix objects to facilitate caching.
In order to have a poolable alternative to PointF, this changeset introduces MPPointF. Convenience methods exist that accept output MPPointF variables for extra savings on pool access. Methods that return recyclable MPPointF instances are documented.
In addition to creating a resized label sizes array, copy old FSize instances to the new array to cut down on the need to get instances from pool. Recycle to pool if the labels shrank.
Replace all "new PointD()" instantiations with PointD.getInstance() / PointD.recycleInstance() pairs. Helper methods overloaded to include void return / output PointD variable signatures. Old methods remain as convenience, with notations that they return recyclable instances.