JUCE
JUCE copied to clipboard
[Bug]: Slow access to XmlElement attributes
Detailed steps on how to reproduce the bug
XmlElement doesn't expose its linked list attributes at all, nor does it expose an iterator over it. This means that it's not possible to efficiently iterate over all attributes.
Currently, the only way to iterate over attributes is this:
int attrCount = element->getNumAttributes();
for (int i = 0; i < attrCount; i++) {
auto& attrName = element->getAttributeName(i);
auto& attrValue = element->getAttributeValue(i);
Here, getNumAttributes() has to iterate over the entire list, and getAttributeName()/getAttributeValue() both have to iterate over the list to get a specific index every time. This is quite wasteful and can get slow when there are a lot of attributes.
What is the expected behaviour?
I'd expect to be able to walk over attributes without the added performance penalty of things like getNumAttributes() and getAttributeX() iterating over the entire list. This is already possible with XmlElement trees itself, so why not its attributes?
Operating systems
Windows
What versions of the operating systems?
24H2 26100.4061
Architectures
x86_64
Stacktrace
Plug-in formats (if applicable)
No response
Plug-in host applications (DAWs) (if applicable)
No response
Testing on the develop branch
The bug is present on the develop branch
Code of Conduct
- [x] I agree to follow the Code of Conduct