Skip to content

Commit

Permalink
fix lru map with disabled caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhirkevich Alexander Y authored and Zhirkevich Alexander Y committed Jul 10, 2024
1 parent 820bb10 commit 99ad7f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import kotlin.math.roundToInt
* @param clipTextToBoundingBoxes if text should be clipped to its bounding boxes (if provided in animation)
* @param enableTextGrouping disable line-to-char splitting. Enable this to correctly render texts
* in locales such as Arabic. This feature forces to use fonts over glyphs and disables text tracking.
* However, if you have texts rendered with fonts and don't use tracking, you can try enable this option
* for any locales as this feature greatly improves texts performance
* @param enableMergePaths enable experimental merge paths feature. Most of the time animation doesn't need
* it even if it contains merge paths. This feature should only be enabled for tested animations
* @param enableExpressions enable experimental expressions feature. Unsupported expressions will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ internal class LruMap<T : Any>(
private fun putRaw(key: Any, value: T): T? {
val cacheLimit = limit()

while (cacheLimit in 1..size) {
remove(keys.firstOrNull())
if (cacheLimit < 1){
clearRaw()
} else {
while (cacheLimit < size) {
remove(keys.firstOrNull())
}
}

return delegate.put(key, value)
Expand Down

0 comments on commit 99ad7f6

Please sign in to comment.