Skip to content

Commit

Permalink
Store type as ordinal
Browse files Browse the repository at this point in the history
  • Loading branch information
John Rodriguez committed May 11, 2023
1 parent b6d36c2 commit d0ae1e2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ import java.io.File
import java.util.EnumSet

class BasicResourceItem(
private val type: ResourceType,
type: ResourceType,
private val name: String,
file: File,
tag: Element?,
private val repository: SingleNamespaceResourceRepository
) : ResourceItem {
// Store enums as their ordinals in byte form to minimize memory footprint.
private val typeOrdinal: Byte

private val resourceValue: ResourceValue

private val folderConfiguration: FolderConfiguration =
Expand All @@ -69,6 +72,8 @@ class BasicResourceItem(
private val isFileBased = tag == null

init {
typeOrdinal = type.ordinal.toByte()

resourceValue = if (tag == null || type == PUBLIC) {
val density =
if (type == ResourceType.DRAWABLE || type == ResourceType.MIPMAP) configuration.densityQualifier?.value else null
Expand All @@ -83,7 +88,7 @@ class BasicResourceItem(
}
}

override fun getType() = type
override fun getType() = ResourceType.values()[typeOrdinal.toInt()]

override fun getNamespace(): ResourceNamespace = repository.namespace

Expand Down

0 comments on commit d0ae1e2

Please sign in to comment.