Files
servo/components/script_bindings
Simon Wülker 6cc0bfd6fd script: Convert less between string types in range-related methods of HTMLInputElement (#39846)
The current code has snippets like
`self.convert_string_to_number(&DOMString::from(attr.summarize().value))`
in various places.

The snippet wants to take the value of an attribute and parse it as a
number. In theory this is an easy problem, the attribute internally
stores a `AttrValue` (which can be treated as `str`) and the conversion
code wants a `str` - no conversions or copies necessary!

But the reality of what happens is less ideal:
`attr.summarize` allocates a `AttrInfo` containing owned copies of the
attributes namespace, name and value. The name and value are also
converted from the `AttrValue` to a `DOMString` and then back to a
`String` in the process. And then we take the value field from
`AttrInfo` and create a new DOMString from it, passing that to
`self.self.convert_string_to_number` - which ends up internally calling
`str()` on it.

All in all this is not a big issue, because this code doesn't run often.
But it's also not hard to fix, and we end up with cleaner code in the
process.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-14 08:24:30 +00:00
..
2025-09-20 03:09:37 +00:00
2025-08-19 11:07:53 +00:00