fix(article): warm up large single-block articles
The warm-up ran only above a block-count threshold, so an article that parses into one large block never qualified. Trigger on the total character count as well.
This commit is contained in:
1 parent
f3ecc3086c
commit
381ce33017
1 file changed
+4
-1
@@ -13,11 +13,14 @@ import kotlinx.coroutines.currentCoroutineContext
|
|||||||
import kotlinx.coroutines.ensureActive
|
import kotlinx.coroutines.ensureActive
|
||||||
|
|
||||||
internal const val HEAVY_ARTICLE_BLOCK_COUNT = 100
|
internal const val HEAVY_ARTICLE_BLOCK_COUNT = 100
|
||||||
|
internal const val HEAVY_ARTICLE_TOTAL_CHARS = 1_500
|
||||||
|
|
||||||
object ArticleTextWarmUp {
|
object ArticleTextWarmUp {
|
||||||
|
|
||||||
suspend fun warmUp(context: Context, blocks: List<DslBlock>) {
|
suspend fun warmUp(context: Context, blocks: List<DslBlock>) {
|
||||||
if (blocks.size <= HEAVY_ARTICLE_BLOCK_COUNT) return
|
if (blocks.size <= HEAVY_ARTICLE_BLOCK_COUNT &&
|
||||||
|
blocks.sumOf { it.text.length } <= HEAVY_ARTICLE_TOTAL_CHARS
|
||||||
|
) return
|
||||||
val density = Density(context)
|
val density = Density(context)
|
||||||
val measurer = TextMeasurer(
|
val measurer = TextMeasurer(
|
||||||
defaultFontFamilyResolver = createFontFamilyResolver(context),
|
defaultFontFamilyResolver = createFontFamilyResolver(context),
|
||||||
|
|||||||
Reference in new issue
Block a user