mirror of
https://github.com/pachli/pachli-android.git
synced 2025-02-09 08:28:43 +01:00
By Christophe Beyls in https://github.com/tuskyapp/Tusky/pull/4515. Their commit notes: Improve the performance of `BlurHashDecoder` while also reducing memory allocations. - Precompute cosines tables before composing the image so each cosine value is only computed once. - Compute cosines tables once if both are identical (for square images with the same number of colors in both dimensions). - Store colors in a one-dimension array instead of a two-dimension array to reduce memory allocations. - Use a simple String.indexOf() to find the index of a Base83 char, which is both faster and needs less memory than a HashMap thanks to better locality and no boxing of chars. - No cache is used, so computations may be performed in parallel on background threads without the need for synchronization which limits throughput.