public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: colbuse@ensisun.imag.fr
To: Russell King <rmk+lkml@arm.linux.org.uk>, linux-kernel@vger.kernel.org
Subject: Re: [patch 3/2] drivers/char/vt.c: remove unnecessary code
Date: Mon, 28 Feb 2005 15:01:15 +0100	[thread overview]
Message-ID: <1109599275.4223242b6b560@webmail.imag.fr> (raw)
In-Reply-To: <20050228132849.B16460@flint.arm.linux.org.uk>

Surlignage Russell King <rmk+lkml@arm.linux.org.uk>:

> On Mon, Feb 28, 2005 at 02:13:57PM +0100, colbuse@ensisun.imag.fr wrote:
> > NPAR times :-). As I stated, npar is unsigned.
> 
> I think that's disgusting then - it isn't obvious what's going on, which
> leads to mistakes.
> 
> For the sake of a micro-optimisation such as this, it's far more important
> that the code be readable and easily understandable.
> 
> Others may disagree.
> 

I agree :) . But, if we look to the code, we can notice that there is actually
no reason for npar to be unsigned. What do you think of this version?


--- old/drivers/char/vt.c       2004-12-24 22:35:25.000000000 +0100
+++ new/drivers/char/vt.c       2005-02-28 12:53:57.933256631 +0100
@@ -1655,9 +1655,9 @@
                        vc_state = ESnormal;
                return;
        case ESsquare:
-               for(npar = 0 ; npar < NPAR ; npar++)
+               for(npar = NPAR - 1; npar >= 0; npar--)
                        par[npar] = 0;
+               npar++;
-               npar = 0;
                vc_state = ESgetpars;
                if (c == '[') { /* Function key */
                        vc_state=ESfunckey;


--- old/include/linux/console_struct.h  2004-12-24 22:33:48.000000000 +0100
+++ old/include/linux/console_struct.h  2005-02-28 14:49:53.653616335 +0100
@@ -44,7 +44,8 @@
        unsigned short  vc_video_erase_char;    /* Background erase character */
        /* VT terminal data */
        unsigned int    vc_state;               /* Escape sequence parser state */
-       unsigned int    vc_npar,vc_par[NPAR];   /* Parameters of current escape
sequence */
+       unsigned int    vc_par[NPAR];           /* Parameters of current escape
sequence */
+       int             vc_npar;                /* Current position in vc_par */
        struct tty_struct *vc_tty;              /* TTY we are attached to */
        /* mode flags */
        unsigned int    vc_charset      : 1;    /* Character set G0 / G1 */


--
Emmanuel Colbus
Club GNU/Linux
ENSIMAG - Departement telecoms


-------------------------------------------------
envoyé via Webmail/IMAG !


  reply	other threads:[~2005-02-28 14:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-28 13:13 [patch 3/2] drivers/char/vt.c: remove unnecessary code colbuse
2005-02-28 13:28 ` Russell King
2005-02-28 14:01   ` colbuse [this message]
2005-02-28 14:22     ` Arjan van de Ven
2005-02-28 14:43     ` Martin Mares
2005-02-28 14:57     ` Horst von Brand
2005-02-28 13:32 ` Adrian Bunk
2005-02-28 13:48 ` Dmitry Torokhov
2005-02-28 14:02   ` Arjan van de Ven
2005-02-28 14:06     ` Dmitry Torokhov
  -- strict thread matches above, loose matches on Subject: below --
2005-02-28 15:06 colbuse
2005-02-28 16:44 ` Stelian Pop
2005-02-28 17:29   ` emmanuel.colbus@ensimag.imag.fr
2005-02-28 19:18     ` Stelian Pop
2005-02-28 20:30     ` Adrian Bunk
2005-02-28 12:57 colbuse
2005-02-28 13:02 ` Russell King
2005-02-28 13:33 ` linux-os

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1109599275.4223242b6b560@webmail.imag.fr \
    --to=colbuse@ensisun.imag.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+lkml@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox