Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upscript: Stop reallocating so much when converting DOM strings to JS values. #7765
Conversation
values. `size_hint()` in `utf16_units()` seems busted, so we do it ourselves.
|
@bors-servo: r+ |
|
|
|
|
…it, r=jdm script: Stop reallocating so much when converting DOM strings to JS values. This is split out from #6900. `size_hint()` in `utf16_units()` seems busted, so we do it ourselves. r? @jdm <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7765) <!-- Reviewable:end -->
|
|
|
Can we get a bug filed on the size hint? On first sight, it looks correctly implemented. |
|
The Since Since the range of code points that take 4 UTF-8 bytes happens to be the same as those taking two UTF-16 units (non-BMP), with specialization, we could tighten The real problem here is that |
|
Also CC @gankro |
|
Using the upper bound would likely cause many programs to waste extreme amounts of memory, to the point of even OOMing on preposterous bounds. This just an instance of "inherent complexity". We can't magically know what you want the hint for, nor what kind of reallocation strategy you're interested in. If you know better, ya gotta Using lower_bound unconditionally seems like the most well-behaved option. The standard library will always be suboptimal since we're generic, and therefore cannot leverage specific data properties (other than reasoning about "common" applications). |
|
(IMHO, upper bound is basically useless in a generic context) |
|
Alright, sounds reasonable. Based on this comment and IRC discussion it sounds like there is no |
pcwalton commentedSep 27, 2015
This is split out from #6900.
size_hint()inutf16_units()seems busted, so we do it ourselves.r? @jdm