-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove String#casecmp
part
#123
Comments
maybe a compromise here is to have so we have the comparison, but the problem is front and center? |
What? I think guides should promotes international (Unicode) ways, not ASCII-only (read as English-only). |
Many use cases are ASCII-only. I think it's still valid to retain benchmarks for those situations. Ruby even provides As an addendum, every Ruby implementation optimizes for ASCII. It's not a value statement. It's just that ASCII characters are byte wide, which makes optimizing for them very easy. UTF-16 and UTF-32 are also somewhat optimized given they have fixed width encodings. UTF-8 complicates things by virtue of variable width characters. As a simple test, benchmark I'm sensitive to ensuring code works with all character sets. But to the extent that this is a set of benchmarks that are context-sensitive, I think it makes sense to lay out that context. Really, all the |
I agree with @kbrock and @nirvdrum. There's no good reason to restrict things to UTF-8 because all things should be international. They should follow the actual use cases. @AlexWayfer do you think you can edit your PR to keep the old |
The strings in Ruby are UTF-8 by default. Do you know about Ruby's I think it's a very good reason.
And rules about different non-clear use cases should not exist, at least be turned off by default (if we're talking about linting).
I can, but I don't want. For what? The suggested "by international community" rule doesn't work with a lot of lanuagues, hungreds probably. The significant majority of our world. I don't want to suggest to use a method which doesn't work correctly in most languages (strings are about texts, texts are written in languages) for a little performance. And I don't want to receive such suggestions. In the same project in one case you'll be warned and it'll work and you're fine. In another, with another language, probably dynamically (what is difficult to investigate and analyze) it will be broken (just @mateusdeap doi you think you can create a PR to Ruby to fix the |
To clear up confusion, I just want to clear up that "ASCII" here doesn't literally mean the US-ASCII encoding, but rather UTF-8 with characters that are drawn from ASCII (as UTF-8 is ASCII-compatible). I have a few other parting thoughts:
|
The
String#casecmp
method does not work with Unicode (even in Ruby 2.4.1), this is written in the documentation.Example:
There is a method
String#casecmp?
, which works with Unicode.Example:
But
String.casecmp?
is slower:Code
So,
String#downcase + ==
is good compromise.The text was updated successfully, but these errors were encountered: