classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cp-patches] RFC: StringIndexOutOfBoundsException fixes inString con


From: Anthony Balkissoon
Subject: RE: [cp-patches] RFC: StringIndexOutOfBoundsException fixes inString contructors
Date: Wed, 02 Nov 2005 10:33:30 -0500

On Wed, 2005-11-02 at 12:50 +0100, Jeroen Frijters wrote:
> Christian Thalinger wrote:
> > +    if (offset + count < 0 || offset + count > ascii.length)
> 
> You can write this more efficiently as:
> 
>     if (ascii.length - offset < count)
> 
> (This assumes that offset and count have previously been checked to be
> non-negative.)
> 
> Regards,
> Jeroen
> 

Uhm, I think that offset and count probably wouldn't have been checked
to be non-negative, otherwise why would they check that offset + count <
0 ?

--Tony





reply via email to

[Prev in Thread] Current Thread [Next in Thread]