Skip to content

Faster way to fetch specific attributes? #112

Open
@GnomedDev

Description

@GnomedDev

Is your feature request related to a problem? Please describe.
Currently, in order to fetch a couple attributes:

  1. JS has to create a bunch of Attribute classes
  2. Collect them into a array
  3. Iterate over this array
  4. Read attribute name into a string
  5. Check if the attribute name is correct
  6. Read the desired attribute value into a string and store it
  7. Repeat from 4 until all fields are collected

This is inefficient, as we only really want to iterate over the XML and do 5, 6 and 7

Describe the solution you'd like
An API such as Tag.extractAttributes() which takes a list of keys and returns the key: value pairs in an object. This would be able to skip Attribute construction, the double iteration, and even some string conversions with extra optimization.

Describe alternatives you've considered
My existing solution works, but could be quicker.

Additional context
23% of profiled time in my application is spent in get attributes(), which is a waste, alongside 13% of time spent in get value() for Text during this loop which could be reduced with smarter key comparisons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions