2005-02-28 12:55:51

by [email protected]

[permalink] [raw]
Subject: [patch 2/2] drivers/chat/vt.c: remove unnecessary code


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


Signed-off-by: Emmanuel Colbus <[email protected]>


--- old/drivers/char/vt.c 2004-12-24 22:35:25.000000000 +0100
+++ new/drivers/char/vt.c 2005-02-28 12:56:46.154311486 +0100
@@ -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 !


2005-02-28 14:46:19

by Andries Brouwer

[permalink] [raw]
Subject: Re: [patch 2/2] drivers/chat/vt.c: remove unnecessary code

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

2005-02-28 15:16:22

by [email protected]

[permalink] [raw]
Subject: Re: [patch 2/2] drivers/chat/vt.c: remove unnecessary code



>On Mon, Feb 28, 2005 at 01:55:28PM +0100, colbuse@xxxxxxxxxxxxxxx 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.


I didn't thought to that point...

You're right, this patch was a bad idea :(.

Sorry about this error...

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

-------------------------------------------------
envoy? via Webmail/IMAG !