Skip to contentSkip to conversation

drivers/char/vt.c: remove unnecessary code

PATCH [email protected] 3 participants 3 messages Feb 28, 2005 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

We could change an affectation into an incrementation by this patch, and, so far I know, incrementing is quicker than or as quick as setting a variable (depends on the architecture).

Please _don't_ apply this, but tell me what you think about it. Note that npar is unsigned.

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

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

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

#1 lore raw
Quoted 1 line · On Mon, Feb 28, 2005 at 01:57:59PM +0100, [email protected] wrote:

Please _don't_ apply this, but tell me what you think about it.

It's broken. 8)

drivers/char/vt.c 2005-02-28 12:53:57.933256631 +0100 line 1658

Quoted 8 lines
drivers/char/vt.c 2005-02-28 12:53:57.933256631 +0100 renamed from drivers/char/vt.c 2004-12-24 22:35:25.000000000 +0100 +1 -1
@@ -1655,9 +1655,9 @@
                        vc_state = ESnormal;
                return;
        case ESsquare:
-               for(npar = 0 ; npar < NPAR ; npar++)
+               for(npar = NPAR-1; npar < NPAR; npar--)

How many times do you want this for loop to run?

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#2 lore raw
In reply to [email protected]
Quoted 9 lines · On Mon, 28 Feb 2005 [email protected] wrote:

We could change an affectation into an incrementation by this patch, and, so far I know, incrementing is quicker than or as quick as setting a variable (depends on the architecture).

Please _don't_ apply this, but tell me what you think about it. Note that npar is unsigned.

Since it is common practice to write code as:
for(npar = 0 ; npar < NPAR ; npar++)
... it is quite likely that the compiler does a better job with that code than what you substitute. And, if you did a check of the code generation, it might be different between different compiler versions.

This kind of "code optimization" won't optimize anything in the long-run.

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

Emmanuel Colbus
Club GNU/Linux
ENSIMAG - departement telecoms

Cheers,
Dick Johnson
Penguin : Linux version 2.6.10 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.