You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Arne Plöse (JIRA)" <ji...@apache.org> on 2011/07/22 08:46:57 UTC

[jira] [Created] (MATH-627) superfluously null check of SparseIterator.next()

superfluously null check of SparseIterator.next()
-------------------------------------------------

                 Key: MATH-627
                 URL: https://issues.apache.org/jira/browse/MATH-627
             Project: Commons Math
          Issue Type: Improvement
    Affects Versions: 3.0
            Reporter: Arne Plöse
            Priority: Minor


Looking at the implementation of SparseIterator in OpenMapRealVector.OpenMapSparseIterator there is no chance that the entry return by next() is ever null - so there is no need to chek this in nearly every loop?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Resolved] (MATH-627) superfluously null check of SparseIterator.next()

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Neidhart resolved MATH-627.
----------------------------------

    Resolution: Fixed

Fixed in r1334198.

Thanks for the report!
                
> superfluously null check of SparseIterator.next()
> -------------------------------------------------
>
>                 Key: MATH-627
>                 URL: https://issues.apache.org/jira/browse/MATH-627
>             Project: Commons Math
>          Issue Type: Improvement
>            Reporter: Arne Plöse
>            Priority: Minor
>             Fix For: 3.1
>
>
> Looking at the implementation of SparseIterator in OpenMapRealVector.OpenMapSparseIterator there is no chance that the entry return by next() is ever null - so there is no need to chek this in nearly every loop?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (MATH-627) superfluously null check of SparseIterator.next()

Posted by "Thomas Neidhart (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13254432#comment-13254432 ] 

Thomas Neidhart commented on MATH-627:
--------------------------------------

I did some performance tests, and the gain is quite significant: ~50%

Removing the additional null check for the data retrieved from it.next() looks safe to me, the code would change to something like that (which btw was already there at some places):

{noformat}
   while (it.hasNext()) {
      final Entry e = it.next();
      ...
   }
{noformat}
                
> superfluously null check of SparseIterator.next()
> -------------------------------------------------
>
>                 Key: MATH-627
>                 URL: https://issues.apache.org/jira/browse/MATH-627
>             Project: Commons Math
>          Issue Type: Improvement
>            Reporter: Arne Plöse
>            Priority: Minor
>             Fix For: 3.1
>
>
> Looking at the implementation of SparseIterator in OpenMapRealVector.OpenMapSparseIterator there is no chance that the entry return by next() is ever null - so there is no need to chek this in nearly every loop?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (MATH-627) superfluously null check of SparseIterator.next()

Posted by "Arne Plöse (Commented JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13253536#comment-13253536 ] 

Arne Plöse commented on MATH-627:
---------------------------------

Sorry for beeing sloppy...

If you look at ArrayRealVector you will find this construct:
{code}
            while (it.hasNext() && (e = it.next()) != null) {...}
{code}            
the same can also be found in RealVector 
                
> superfluously null check of SparseIterator.next()
> -------------------------------------------------
>
>                 Key: MATH-627
>                 URL: https://issues.apache.org/jira/browse/MATH-627
>             Project: Commons Math
>          Issue Type: Improvement
>            Reporter: Arne Plöse
>            Priority: Minor
>             Fix For: 3.1
>
>
> Looking at the implementation of SparseIterator in OpenMapRealVector.OpenMapSparseIterator there is no chance that the entry return by next() is ever null - so there is no need to chek this in nearly every loop?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (MATH-627) superfluously null check of SparseIterator.next()

Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Steitz updated MATH-627:
-----------------------------

    Affects Version/s:     (was: 3.0)
        Fix Version/s: 3.1

Optimization can wait until 3.1

> superfluously null check of SparseIterator.next()
> -------------------------------------------------
>
>                 Key: MATH-627
>                 URL: https://issues.apache.org/jira/browse/MATH-627
>             Project: Commons Math
>          Issue Type: Improvement
>            Reporter: Arne Plöse
>            Priority: Minor
>             Fix For: 3.1
>
>
> Looking at the implementation of SparseIterator in OpenMapRealVector.OpenMapSparseIterator there is no chance that the entry return by next() is ever null - so there is no need to chek this in nearly every loop?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (MATH-627) superfluously null check of SparseIterator.next()

Posted by "Thomas Neidhart (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13253398#comment-13253398 ] 

Thomas Neidhart commented on MATH-627:
--------------------------------------

I failed to find any null check in the mentioned iterator, neither in the current trunk version nor in the version at the time the issue was created. Can you please specify more precisely where the problem lies?
                
> superfluously null check of SparseIterator.next()
> -------------------------------------------------
>
>                 Key: MATH-627
>                 URL: https://issues.apache.org/jira/browse/MATH-627
>             Project: Commons Math
>          Issue Type: Improvement
>            Reporter: Arne Plöse
>            Priority: Minor
>             Fix For: 3.1
>
>
> Looking at the implementation of SparseIterator in OpenMapRealVector.OpenMapSparseIterator there is no chance that the entry return by next() is ever null - so there is no need to chek this in nearly every loop?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira