RSS/Atom feed Twitter
Site is read-only, email is disabled

Scope of variables

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

4 of 4 messages available
Toggle history

Please log in to manage your subscriptions.

Scope of variables Nelson A. de Oliveira 18 Nov 03:23
  Scope of variables Nelson A. de Oliveira 18 Nov 03:25
  Scope of variables Martin Nordholts 18 Nov 07:25
  Scope of variables Sven Neumann 18 Nov 18:24
Nelson A. de Oliveira
2009-11-18 03:23:07 UTC (about 15 years ago)

Scope of variables

Hi!

Is it interesting to limit the scope of the variables to where they are only used?
For example, i is not used inside only one if here in app/core/gimpimage-convert.c (and thus has been moved to where it's only necessary):

--- app/core/gimpimage-convert.c.old 2009-11-18 00:18:55.000000000 -0200 +++ app/core/gimpimage-convert.c 2009-11-18 00:19:34.000000000 -0200 @@ -835,8 +835,6 @@
/* Convert to indexed? Build histogram if necessary. */ if (new_type == GIMP_INDEXED)
{
- gint i;
-
/* fprintf(stderr, " TO INDEXED(%d) ", num_cols); */

/* don't dither if the input is grayscale and we are simply @@ -897,6 +895,7 @@
! needs_quantize &&
palette_type == GIMP_MAKE_PALETTE) {
+ gint i;
/* If this is an RGB image, and the user wanted a custom-built * generated palette, and this image has no more colours than * the user asked for, we don't need the first pass (quantization).

Are these kind of minor changes interesting for Gimp, please?

Thank you!

Best regards, Nelson

Nelson A. de Oliveira
2009-11-18 03:25:04 UTC (about 15 years ago)

Scope of variables

Hi again!

On Wed, Nov 18, 2009 at 12:23 AM, Nelson A. de Oliveira wrote:

For example, i is not used inside only one if here in app/core/gimpimage-convert.c (and thus has been moved to where it's only necessary):

I need to sleep.
Read it as: "For example, i is used inside only one if here in app/core/gimpimage-convert.c"

Martin Nordholts
2009-11-18 07:25:51 UTC (about 15 years ago)

Scope of variables

Nelson A. de Oliveira wrote:

Hi!

Is it interesting to limit the scope of the variables to where they are only used?

Hi!

Yes, but this is the kind of changes you'd do when you have commit access. It would be too much work to review a big inflow of these kinds of patches.

Regards,
Martin

Sven Neumann
2009-11-18 18:24:59 UTC (about 15 years ago)

Scope of variables

On Wed, 2009-11-18 at 00:23 -0200, Nelson A. de Oliveira wrote:

--- app/core/gimpimage-convert.c.old 2009-11-18 00:18:55.000000000 -0200 +++ app/core/gimpimage-convert.c 2009-11-18 00:19:34.000000000 -0200 @@ -835,8 +835,6 @@
/* Convert to indexed? Build histogram if necessary. */ if (new_type == GIMP_INDEXED)
{
- gint i;
-
/* fprintf(stderr, " TO INDEXED(%d) ", num_cols); */

/* don't dither if the input is grayscale and we are simply @@ -897,6 +895,7 @@
! needs_quantize &&
palette_type == GIMP_MAKE_PALETTE) {
+ gint i;
/* If this is an RGB image, and the user wanted a custom-built * generated palette, and this image has no more colours than * the user asked for, we don't need the first pass (quantization).

There's a missing newline after the moved declaration.

Sven