4 ms·
The trick is that through their mapping, they have an array of "attributes" for every element, with a specific offset for each attribute with a certain name. Du
by Nitramp 16y ago
The trick is that through their mapping, they have an array of "attributes" for every element, with a specific offset for each attribute with a certain name. During construction, they build that array according to the names, so they do the lookup once during construction.
- roel_v 16y agoBut then how do you reference the attributes? I get the code to parse my xml document, then afterward I want to access a certain attribute (by name). The library would still need to look up the index of that attribute, at O(n) complexity, right?
- lincolnq 16y agono, quoting from grandparent: "a specific offset for each attribute with a certain name" -- e.g., for all <image> element, 'width' is always at attributes[0] and 'height' is at attributes[1], presumably regardless of whether that particular image has a width and height attribute.
- roel_v 16y agoOh I see, thanks.