harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sian January (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-5682) [classlib][pack200] Sped up hashCode and removed dead getCpAll()
Date Thu, 03 Apr 2008 09:04:24 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-5682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12585016#action_12585016
] 

Sian January commented on HARMONY-5682:
---------------------------------------

I think it's reasonable to assume that utf8 is never null in this case.  Surely it would be
a bug if we created a CPUTF8 with a null utf8 anyway?  So if that's true it's probably good
that we throw a NullPointerException.  The slightly better alternative could be to throw it
in the constructor and document that. e.g. :

/**
 * @throws NullPointerException if utf8 is null
 */
public CPUTF8(String utf8, int domain) {
    ...
    if (utf8 == null) {
       throw new NullPointerException("Null utf8 not allowed");
    }
}

> [classlib][pack200] Sped up hashCode and removed dead getCpAll()
> ----------------------------------------------------------------
>
>                 Key: HARMONY-5682
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5682
>             Project: Harmony
>          Issue Type: Improvement
>          Components: Classlib
>         Environment: All Pack200
>            Reporter: Andrew Cornwall
>            Assignee: Sian January
>         Attachments: main.patch
>
>
> This patch does two things, one of which may be controversial.
> The uncontroversial code removes SegmentConstantPool.getCpAll(), since it is no longer
used.
> The other code changes hashCode in CPUTF8, CPClass and CPRef. Because hashCode is used
frequently, making it fast is a good idea. In the pack200 code as it exists, hashCode is never
called for CPUTF8, CPClass or CPRef unless all instance variables have been set. The changes
to hashCode make the assumption that this will always hold. As a consequence, hashCode will
throw a NullPointerException when sent to uninitialized instances of these classes.
> The changes to hashCode do improve runtime by about 10%.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message