-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XML resource optimizations #4559
Conversation
To avoid slow XML parsing
…pare resources task
} | ||
} | ||
|
||
override suspend fun readPart(path: String, offset: Long, size: Long): ByteArray { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we read the whole file on web on each string resource? I would cache byte array by path then
.map { it.nodeName to it.attributes.getNamedItem("name").nodeValue } | ||
private fun getValueResourceItems(dataFile: File, qualifiers: List<String>, path: Path) : List<ResourceItem> { | ||
val result = mutableListOf<ResourceItem>() | ||
RandomAccessFile(dataFile, "r").use { f -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple BufferedReader(FileReader) can be used here as you don't use random access in fact (you could use for file positions instead of calculating offsets manually).
Users noticed if an app has big a
string.xml
file it affects the app startup time: #4537The problem is slow XML parsing.
Possible ways for optimization:
We selected the second way because texts injected to source code have several problems:
Things was done in the PR:
values
directoryRes.array
accessor for string-array resourcesvalues*/*.xml
files. There will be convertedvalues*/*.cvr
files.compose.resources.always.generate.accessors
was deleted. It was for internal needs only.Fixes #4537