classpath
[Top][All Lists]
Advanced

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

Re: [patch] fix to BufferedImage


From: graydon hoare
Subject: Re: [patch] fix to BufferedImage
Date: 17 Sep 2003 12:24:47 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Tom Tromey <address@hidden> writes:

> graydon> +        // slower path
> graydon> +        int samples[] = null;
> graydon> +        samples = src.getPixels (x, y, w, h, samples);
> 
> The `null' here is redundant; there are a couple of these.
> I'd either do the assignment and declaration at once, or just not
> initialize samples.  (In java this is always safe due to the definite
> assignment rules.)

yeah, I'm aware that the null initialization is redundant in java;
that's probably just a C++ habit leaking through. I'll remove that.

the assignment however cannot coincide with the declaration, because
this is one of those "efficiency oriented" java APIs (pass in null if
you want the callee to allocate the array), and writing a literal
"null" in position of the "samples" argument degrades the type of the
argument to Object, which ambiguates the call: there's an overload for
each of int[], double[] and float[].

-graydon





reply via email to

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