add knownMimeTypesMap

This commit is contained in:
InsanusMokrassar 2020-08-20 12:58:14 +06:00
parent 2e2632caae
commit 96217eb3ed

View File

@ -8,8 +8,6 @@ interface MimeType {
}
data class CustomMimeType(override val raw: String) : MimeType
private const val imageMainType = "image"
sealed class KnownMimeTypes(override val raw: String) : MimeType {
object Any : MimeType, KnownMimeTypes("*/*")
sealed class Application(raw: String) : MimeType, KnownMimeTypes(raw) {
@ -1437,6 +1435,10 @@ internal val knownMimeTypes: Set<MimeType> = setOf(
KnownMimeTypes.XConference.XCooltalk,
)
fun findBuiltinMimeType(from: String): MimeType? {
return knownMimeTypes.firstOrNull { it.raw == from }
val knownMimeTypesMap by lazy {
knownMimeTypes.associateBy { it.raw }
}
fun findBuiltinMimeType(from: String): MimeType? {
return knownMimeTypesMap[from]
}