kafka-jira mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KAFKA-6218) Optimize condition in if statement to reduce the number of comparisons
Date Thu, 16 Nov 2017 03:26:00 GMT

    [ https://issues.apache.org/jira/browse/KAFKA-6218?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16254692#comment-16254692
] 

ASF GitHub Bot commented on KAFKA-6218:
---------------------------------------

GitHub user sachinbhalekar opened a pull request:

    https://github.com/apache/kafka/pull/4225

    KAFKA-6218 : Optimize condition in if statement to reduce the number of comparisons

    
    Changed the condition in **if** statement 
    **(schema.name() == null || !(schema.name().equals(LOGICAL_NAME)))** which
    requires two comparisons in worst case with
    **(!LOGICAL_NAME.equals(schema.name()))**  which requires single comparison
    in all cases and _avoids null pointer exception.
    ![kafka_optimize_if](https://user-images.githubusercontent.com/32234013/32872271-afe0b954-ca3a-11e7-838d-6a3bc416b807.JPG)
    _
    
    ### Committer Checklist (excluded from commit message)
    - [+ ] Verify design and implementation 
    - [+ ] Verify test coverage and CI build status
    - [+ ] Verify documentation (including upgrade notes)


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/sachinbhalekar/kafka trunk

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/kafka/pull/4225.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #4225
    
----
commit 0a0058cb680ce319794d26dcabc8c6c4415d2684
Author: sachinbhalekar <32234013+sachinbhalekar@users.noreply.github.com>
Date:   2017-11-16T02:40:59Z

    Merge pull request #2 from apache/trunk
    
    get latest code

commit 2281e2fbab8d0ff65f56414d0bbb1d0cb2a2a9ad
Author: sachinbhalekar <sachinbansibhalekar@gmail.com>
Date:   2017-11-16T02:49:42Z

    Changed the condition in if statement
    (schema.name() == null || !(schema.name().equals(LOGICAL_NAME))) which
    requires two comparisons in worst case with
    (!LOGICAL_NAME.equals(schema.name()))  which requires single comparison
    in all cases and avoids null pointer exception.

----


> Optimize condition in if statement to reduce the number of comparisons
> ----------------------------------------------------------------------
>
>                 Key: KAFKA-6218
>                 URL: https://issues.apache.org/jira/browse/KAFKA-6218
>             Project: Kafka
>          Issue Type: Improvement
>          Components: KafkaConnect
>    Affects Versions: 0.9.0.0, 0.9.0.1, 0.10.0.0, 0.10.0.1, 0.10.1.0, 0.10.1.1, 0.10.2.0,
0.10.2.1, 0.11.0.0, 0.11.0.1, 1.0.0
>            Reporter: sachin bhalekar
>            Priority: Trivial
>              Labels: newbie
>         Attachments: kafka_optimize_if.JPG
>
>
> Optimizing the condition in *if *statement 
> *(schema.name() == null || !(schema.name().equals(LOGICAL_NAME)))* which
> requires two comparisons in worst case with
> *(!LOGICAL_NAME.equals(schema.name()))*  which requires single comparison
> in all cases and _avoids null pointer exception_.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message