Uh oh!
There was an error while loading. Please reload this page.
Add to_ascii_upper, to_ascii_lower and eq_ignore_ascii_case in std::ascii - #8231
Conversation
brson
commented
Aug 2, 2013
On first glance this seems fairly specialized to Servo's use cases - CSS and HTML. I'd be curious to know if there are others. We need to be cautious about adding features to both |
Kimundi
commented
Aug 2, 2013
Also, we already have See also #5822 |
SimonSapin
commented
Aug 2, 2013
I use http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#ascii-case-insensitive It is gonna be needed in a bunch of different libraries. The options are:
I’d really prefer to avoid all but the last of these options. Would it be better to have these in the |
Kimundi
commented
Aug 2, 2013
If they go in std, than placing them into std::ascii would probably the best. |
thestinger
commented
Aug 3, 2013
I'm fine with it being implemented in |
SimonSapin
commented
Aug 3, 2013
Updated pull request: have functions in
Maybe I should not worry about it and replace it with |
Kimundi
commented
Aug 3, 2013
Could you unify the UPPER_MAP and LOWER_MAP case folding with the case folding for Both seem to do the same thing, so having two wildly different implementations in the same module seems kinda unnecessary. (As an aside: is there a specific reason why you need a lookup table for ascii here? Isn't case in the ascii range just defined by a single bit?) Same thing with function naming: Consistency would be nice here too. Lastly, it would be nice if you could methodify the new functions where applicable (add a |
SimonSapin
commented
Aug 3, 2013
About naming/unification: The Still, please indicate the naming / kind of interface that you prefer and I can update this pull request. About implementation: Yes, case in the ASCII range is a single bit. These function can be implemented in at least two ways: with a lookup in a 256-byte vector, or with a bit flip conditioned by two comparisons. I don’t really know which is faster or otherwise better, but I went with the former as it seems to be what CPython and my system’s libc are doing. I could change |
Kimundi
commented
Aug 3, 2013
Sure, not talking about converting it to All the No idea which one is faster, so maybe just use the bitflip one because it is shorter? |
SimonSapin
commented
Aug 5, 2013
Another way to implement this is with a match on a range pattern (leaving to the compiler how to implement that.) A micro-benchmark show that the lookup table is 1.2x ~ 2.2x faster than either other solution: https://gist.github.com/SimonSapin/6156068#file-summary Upadated PR: change |
SimonSapin
commented
Aug 6, 2013
On noes! The build failed because of |
Original pull request: Add str.to_ascii_lower() and str.to_ascii_upper() methods in std::str.
Fix `implicit_clone` for `&&T` fixesrust-lang#8227 changelog: Don't lint `implicit_clone` on `&&T`
8231: Fold consecutive consts and statics r=matklad a=MozarellaMan PR to implement rust-lang#8114  Co-authored-by: Ayomide Bamidele <ayoeze@hotmail.com>
Original pull request: Add str.to_ascii_lower() and str.to_ascii_upper() methods in std::str.