Wed, 16 Jun 2010 21:24:33 +0100 Andrew John Hughes <ahug...@redhat.com>:

> On 23:02 Wed 16 Jun     , Ivan Maidanski wrote:
> > Hi!
> > 
> > This patch contains:
> > - a fix for Bidi constructor ("text" field wasn't initialized);
> 
> Good catch.  I presume the constructor currently throws an NPE?

Yes. (Seems no one else uses this class.)

> 
> > - 2 code optimizations (for speed) in Bidi and CollationElementIterator).
> > 
> 
> Could you document how the optimization version works?  It isn't immediately
> clear to me.

For requiresBidi():

1. the optimization is:
 (v != const1 && ... && v != constN)
->
 ((1 << v) & const) !=0, where const = (1 << const1) | ... | (1 << constN).

2. Character.getDirectionality(c) is always left-to-right if c < HEBREW.

> 
> I fail to see why work_text is being created at all and text not just used
> for the charAt, substring and length operations.  Any ideas?

The only reason is there was a '==' operation.

> 
> > ChangeLog entries:
> >     * java/text/Bidi.java:
> >     (Bidi(AttributedCharacterIterator)): Fix uninitialized "text" field
> >     bug (initialize "text" instance field instead of creating "text" local
> >     variable).
> >     (requiresBidi(char[], int, int)): Optimize the expression (for speed).
> >     * java/text/CollationElementIterator.java:
> >     (setText(String)): Remove intern() call for work_text (since
> >     unnecessary).
> > 
> > Regards.
> 
> Thanks,
> -- 
> Andrew :)
> 
> Free Java Software Engineer
> Red Hat, Inc. (http://www.redhat.com)


Reply via email to