Github user stokito commented on the issue:

    https://github.com/apache/commons-lang/pull/334
  
    I checked and everything is ok in terms of backward compatibility. But the 
commit 7f8571a506c7081bae0cf27bd93295e0344160bf "flips the order of conditional 
expressions and 'if' statements whose conditions were negated." may be not so 
good in terms of code readability.
    First of all, there is always some natural flow when we expect that 
something is more likely happens.
    Let's take a look on the method `addProcessor()`:
    ```java
        private static void addProcessor(final String key, final Processor 
processor) {
            if (!ARCH_TO_PROCESSOR.containsKey(key)) {
                ARCH_TO_PROCESSOR.put(key, processor);
            } else {
                final String msg = "Key " + key + " already exists in processor 
map";
                throw new IllegalStateException(msg);
            }
        }
    ```
    Here developer sees a "happy path" first and only then he or she sees 
exception situation handling.
    This is more natural to understand. As I remember this style was mentioned 
in Complete Code book.
    
    Also this style has slightly better performance because in most situations 
processor will go forward to prefetched instructions or even it can be already 
executed by [branch prediction](https://en.wikipedia.org/wiki/Branch_predictor).
    Meanwhile removing of negation usually doesn't have any performance impact 
because processors have already negated instructions.
    
    I thinks it's ok to merge this commit but I just wan't you to know that 
sometimes it is better to make unnecessary negation.


---

Reply via email to