API(s)
How do you want it to be improved?
Hi guys,
I've noticed that Guava consistently uses string.length() == 0 instead of string.isEmpty(). I'm curious about the reasoning behind this coding style.
After doing some research, I've gathered a few potential reasons:
- Android Compatibility: Guava needs to maintain support for older Android versions while staying on a Java 8 baseline.
- Performance:
length() == 0 might be a more direct property check in some older environments.
- No-churn Policy: The team generally discourages "refactoring for style only" to avoid unnecessary code churn.
However, I'm wondering if there are other factors, such as limited time or bandwidth for such updates. If that’s the case, I’d be happy to help with some minor cleanups—not a massive refactor, just small, focused improvements.
Also, I saw this line, I understand that don't need replacing it with !separator.isEmpty()
checkArgument(separator.length() != 0, "xxxxxxx");
I apologize if this has been discussed before (I couldn't find the exact issue). I would love to hear your thoughts on this.
Thanks in advance!
Why do we need it to be improved?
...
Example
Current Behavior
...
Desired Behavior
...
Concrete Use Cases
...
Checklist
API(s)
How do you want it to be improved?
Hi guys,
I've noticed that Guava consistently uses
string.length() == 0instead ofstring.isEmpty(). I'm curious about the reasoning behind this coding style.After doing some research, I've gathered a few potential reasons:
length() == 0might be a more direct property check in some older environments.However, I'm wondering if there are other factors, such as limited time or bandwidth for such updates. If that’s the case, I’d be happy to help with some minor cleanups—not a massive refactor, just small, focused improvements.
Also, I saw this line, I understand that don't need replacing it with
!separator.isEmpty()I apologize if this has been discussed before (I couldn't find the exact issue). I would love to hear your thoughts on this.
Thanks in advance!
Why do we need it to be improved?
...
Example
Current Behavior
...
Desired Behavior
...
Concrete Use Cases
...
Checklist
I agree to follow the code of conduct.
I have read and understood the contribution guidelines.
I have read and understood Guava's philosophy, and I strongly believe that this proposal aligns with it.