Skip to content

Commit

Permalink
perf: format cache
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Aug 16, 2024
1 parent 8822edd commit b78660d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/main/kotlin/li/songe/gkd/util/TimeExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package li.songe.gkd.util
import java.text.SimpleDateFormat
import java.util.Locale
import java.util.concurrent.TimeUnit
import kotlin.collections.hashMapOf

fun formatTimeAgo(timestamp: Long): String {
val currentTime = System.currentTimeMillis()
Expand All @@ -25,7 +26,7 @@ fun formatTimeAgo(timestamp: Long): String {
}
}

private val formatDateMap = mutableMapOf<String, SimpleDateFormat>()
private val formatDateMap by lazy { hashMapOf<String, SimpleDateFormat>() }

fun Long.format(formatStr: String): String {
var df = formatDateMap[formatStr]
Expand Down

0 comments on commit b78660d

Please sign in to comment.