Skip to contentSkip to conversation

drivers/chat/vt.c: remove unnecessary code

PATCH In review [email protected] 2 participants 2 messages Feb 28, 2005 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 drivers/chat/vt.c: remove unnecessary code

Avoid changing the state of the console two times in some cases.

drivers/char/vt.c 2005-02-28 12:56:46.154311486 +0100 renamed from drivers/char/vt.c 2004-12-24 22:35:25.000000000 +0100 +11 -11
@@ -1571,7 +1571,6 @@
        }
        switch(vc_state) {
        case ESesc:
-               vc_state = ESnormal;
                switch (c) {
                case '[':
                        vc_state = ESsquare;
@@ -1585,25 +1584,25 @@
                case 'E':
                        cr(currcons);
                        lf(currcons);
-                       return;
+                       break;
                case 'M':
                        ri(currcons);
-                       return;
+                       break;
                case 'D':
                        lf(currcons);
-                       return;
+                       break;
                case 'H':
                        tab_stop[x >> 5] |= (1 << (x & 31));
-                       return;
+                       break;
                case 'Z':
                        respond_ID(tty);
-                       return;
+                       break;
                case '7':
                        save_cur(currcons);
-                       return;
+                       break;
                case '8':
                        restore_cur(currcons);
-                       return;
+                       break;
                case '(':
                        vc_state = ESsetG0;
                        return;
@@ -1615,14 +1614,15 @@
                        return;
                case 'c':
                        reset_terminal(currcons,1);
-                       return;
+                       break;
                case '>':  /* Numeric keypad */
                        clr_kbd(kbdapplic);
-                       return;
+                       break;
                case '=':  /* Appl. keypad */
                        set_kbd(kbdapplic);
-                       return;
+                       /* Here, we don't need any break; */
                }
+               vc_state = ESnormal;
                return;
        case ESnonstd:
                if (c=='P') {   /* palette escape sequence */

--
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:55:28PM +0100, [email protected] wrote:

Avoid changing the state of the console two times in some cases.

A bad change for several reasons.

(i) more object code is generated
(ii) the code is slower
(iii) you change something

Straight line code is cheap, jumps are expensive. Replacing an assignment by a jump is not an improvement.

But far worse: this is a purposeless microoptimization.
At least one out of every hundred trivial patches is broken. Thus, a stream of trivial changes will only break the kernel, for no gain.

Andries