[prev in list] [next in list] [prev in thread] [next in thread]
List: elinks-cvs
Subject: [ELinks] elinks - zas: add_char_color(): optimization and cleanup.
From: cvs () pasky ! or ! cz
Date: 2004-04-30 13:53:10
Message-ID: 20040430135310.28846.qmail () machine ! sinus ! cz
[Download RAW message or body]
This is an automated notification of a change to the ELinks CVS tree.
Author: zas
Module: elinks
Tag: <TRUNK>
Date: Fri Apr 30 13:53:10 2004 GMT
---- Log message:
add_char_color(): optimization and cleanup.
---- Files affected:
elinks/src/terminal:
screen.c (1.138 -> 1.139)
http://cvsweb.elinks.or.cz/cvsweb.cgi/elinks/src/terminal/screen.c.diff?r1=1.138&r2=1.139&f=u
---- Diffs:
elinks/src/terminal/screen.c | 40 +++++++++++++++++------------------
1 files changed, 20 insertions(+), 20 deletions(-)
Index: elinks/src/terminal/screen.c
diff -u elinks/src/terminal/screen.c:1.138 elinks/src/terminal/screen.c:1.139
--- elinks/src/terminal/screen.c:1.138 Fri Apr 30 15:33:50 2004
+++ elinks/src/terminal/screen.c Fri Apr 30 15:53:05 2004
@@ -462,39 +462,39 @@
add_char_color(struct string *screen, struct string *seq, unsigned char color)
{
unsigned char color_buf[3];
- unsigned char *color_pos;
- int seq_pos, color_len;
+ unsigned char *color_pos = color_buf;
+ register int seq_pos = 0;
+ int color_len = 1;
check_string_magic(seq);
- for (seq_pos = 0; seq->source[seq_pos] != '%'; seq_pos++) ;
+ for (; seq->source[seq_pos] != '%'; seq_pos++) ;
add_bytes_to_string(screen, seq->source, seq_pos);
- if (color > 9) {
- int color2;
+ if (color < 10) {
+ color_pos += 2;
+ } else {
+ register int color2;
- if (color > 199) {
- color_buf[0] = '2';
- color_pos = color_buf;
- color_len = 3;
- color -= 200;
- } else if (color > 99) {
- color_buf[0] = '1';
- color_pos = color_buf;
- color_len = 3;
- color -= 100;
+ ++color_len;
+ if (color < 100) {
+ color_pos += 1;
} else {
- color_len = 2;
- color_pos = color_buf + 1;
+ ++color_len;
+
+ if (color < 200) {
+ color_buf[0] = '1';
+ color -= 100;
+ } else {
+ color_buf[0] = '2';
+ color -= 200;
+ }
}
color2 = (color % 10);
color /= 10;
color_buf[1] = '0' + color;
color = color2;
- } else {
- color_len = 1;
- color_pos = color_buf + 2;
}
color_buf[2] = '0' + color;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic