diff options
author | Aurélien Aptel <aurelien.aptel@gmail.com> | 2010-10-13 01:27:09 +0200 |
---|---|---|
committer | Aurélien Aptel <aurelien.aptel@gmail.com> | 2010-10-13 01:27:09 +0200 |
commit | 68d8fcf62a4f016c0292db543c1c2e694afc5b54 (patch) | |
tree | b11b9274654d08e142fd24144bc0671c7749570b /st.c | |
parent | e4bf56ae1a9e2612ec9a6faf2aaecd6eadcccaa7 (diff) | |
download | st-68d8fcf62a4f016c0292db543c1c2e694afc5b54.tar.gz st-68d8fcf62a4f016c0292db543c1c2e694afc5b54.zip |
replaced memset by loops in tresize(); turns out it's faster.
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -677,7 +677,7 @@ tsetchar(char c) { | |||
677 | 677 | ||
678 | void | 678 | void |
679 | tclearregion(int x1, int y1, int x2, int y2) { | 679 | tclearregion(int x1, int y1, int x2, int y2) { |
680 | int y, temp; | 680 | int x, y, temp; |
681 | 681 | ||
682 | if(x1 > x2) | 682 | if(x1 > x2) |
683 | temp = x1, x1 = x2, x2 = temp; | 683 | temp = x1, x1 = x2, x2 = temp; |
@@ -690,7 +690,8 @@ tclearregion(int x1, int y1, int x2, int y2) { | |||
690 | LIMIT(y2, 0, term.row-1); | 690 | LIMIT(y2, 0, term.row-1); |
691 | 691 | ||
692 | for(y = y1; y <= y2; y++) | 692 | for(y = y1; y <= y2; y++) |
693 | memset(&term.line[y][x1], 0, sizeof(Glyph)*(x2-x1+1)); | 693 | for(x = x1; x <= x2; x++) |
694 | term.line[y][x].state = 0; | ||
694 | } | 695 | } |
695 | 696 | ||
696 | void | 697 | void |
@@ -1192,7 +1193,7 @@ tputs(char *s, int len) { | |||
1192 | 1193 | ||
1193 | void | 1194 | void |
1194 | tresize(int col, int row) { | 1195 | tresize(int col, int row) { |
1195 | int i; | 1196 | int i, x; |
1196 | int minrow = MIN(row, term.row); | 1197 | int minrow = MIN(row, term.row); |
1197 | int mincol = MIN(col, term.col); | 1198 | int mincol = MIN(col, term.col); |
1198 | int slide = term.c.y - row + 1; | 1199 | int slide = term.c.y - row + 1; |
@@ -1226,8 +1227,10 @@ tresize(int col, int row) { | |||
1226 | for(i = 0; i < minrow; i++) { | 1227 | for(i = 0; i < minrow; i++) { |
1227 | term.line[i] = realloc(term.line[i], col * sizeof(Glyph)); | 1228 | term.line[i] = realloc(term.line[i], col * sizeof(Glyph)); |
1228 | term.alt[i] = realloc(term.alt[i], col * sizeof(Glyph)); | 1229 | term.alt[i] = realloc(term.alt[i], col * sizeof(Glyph)); |
1229 | memset(term.line[i] + mincol, 0, (col - mincol) * sizeof(Glyph)); | 1230 | for(x = mincol; x < col; x++) { |
1230 | memset(term.alt[i] + mincol, 0, (col - mincol) * sizeof(Glyph)); | 1231 | term.line[i][x].state = 0; |
1232 | term.alt[i][x].state = 0; | ||
1233 | } | ||
1231 | } | 1234 | } |
1232 | 1235 | ||
1233 | /* allocate any new rows */ | 1236 | /* allocate any new rows */ |