You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "remeio (via GitHub)" <gi...@apache.org> on 2023/04/14 09:25:05 UTC

[GitHub] [commons-lang] remeio opened a new pull request, #1053: Refactor boolean utils

remeio opened a new pull request, #1053:
URL: https://github.com/apache/commons-lang/pull/1053

   - Remove the unnecessary unboxing
   - Use special boolean values array instead of hard code:
   ```java
         // The left array (index%2==0) is the Boolean.TRUE strings, the right (index%2==1) is the Boolean.FALSE strings.
         // The strings have the same length (index%2==0?index:index+1) for each pair.
         final String[][] booleanValues = new String[][]{
                 {}, {},
                 {"y", "t", "1"}, {"n", "f", "0"},
                 {ON}, {NO},
                 {YES}, {OFF},
                 {TRUE}, {},
                 {}, {FALSE},
         };
   ``` 
   It has two advantages:
   
   1. For `OCP`, if we add new boolean values, we just need adjust the array
   2. Keep the same performance with old code
   
   It is good for short values such as `T`, `OK`, `NOT`, but it is not good for too long values such as `truthful`.
   ```java
   {
     {},
     {},
     {},
     {},
     {},
     {},
     {},  // empty array for seize a seat, :(
     {},
     { "truthful" }, 
    
   }
   ``` 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] garydgregory commented on pull request #1053: Refactor BooleanUtils#toBooleanObject for readability

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #1053:
URL: https://github.com/apache/commons-lang/pull/1053#issuecomment-1509125011

   -1, does not need fixing. The original author obviously coded this method for performance, not readability.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] remeio closed pull request #1053: Refactor BooleanUtils#toBooleanObject for readability

Posted by "remeio (via GitHub)" <gi...@apache.org>.
remeio closed pull request #1053: Refactor BooleanUtils#toBooleanObject for readability
URL: https://github.com/apache/commons-lang/pull/1053


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] garydgregory commented on pull request #1053: Refactor boolean utils

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #1053:
URL: https://github.com/apache/commons-lang/pull/1053#issuecomment-1508671633

   In general, don't change (un)boxing, this is a low level library and we want to see where (un)boxing happens to watch out for NPEs and performance gotchas.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-lang] remeio commented on pull request #1053: Refactor BooleanUtils#toBooleanObject for readability

Posted by "remeio (via GitHub)" <gi...@apache.org>.
remeio commented on PR #1053:
URL: https://github.com/apache/commons-lang/pull/1053#issuecomment-1508745059

   Thanks. And do you thinks the refactor of `BooleanUtils#toBooleanObject` is necessary?
   I think the old code maybe likes hard code.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org