[w3m-dev 03718] Too slow when loading big file with fold_line=1

* etc.c (nextColumn): added
	(calcPosition): use New_N
			rewrite with nextColumn
	(columnLen): added
* file.c (addnewline): rewrite with columnLen
* proto.h (columnLen): added
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2003-01-30 16:39:29 +00:00
parent 2517af675a
commit 0c0438352c
4 changed files with 54 additions and 34 deletions
+11 -1
View File
@@ -1,3 +1,13 @@
2003-01-31 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03718] Too slow when loading big file with fold_line=1
* etc.c (nextColumn): added
(calcPosition): use New_N
rewrite with nextColumn
(columnLen): added
* file.c (addnewline): rewrite with columnLen
* proto.h (columnLen): added
2003-01-31 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> 2003-01-31 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03717] print newline before exec shell command. * [w3m-dev 03717] print newline before exec shell command.
@@ -6975,4 +6985,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1 * release-0-2-1
* import w3m-0.2.1 * import w3m-0.2.1
$Id: ChangeLog,v 1.730 2003/01/30 16:35:34 ukai Exp $ $Id: ChangeLog,v 1.731 2003/01/30 16:39:29 ukai Exp $
+37 -14
View File
@@ -1,4 +1,4 @@
/* $Id: etc.c,v 1.61 2003/01/29 17:10:30 ukai Exp $ */ /* $Id: etc.c,v 1.62 2003/01/30 16:39:34 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include <pwd.h> #include <pwd.h>
#include "myctype.h" #include "myctype.h"
@@ -478,6 +478,22 @@ checkType(Str s, Lineprop **oprop
return s; return s;
} }
static int
nextColumn(int n, char *p, Lineprop *pr)
{
if (*p == '\t' && *pr == PC_CTRL)
return (n + Tabstop) / Tabstop * Tabstop;
#ifndef KANJI_SYMBOLS
else if (*pr & PC_RULE)
return n + 1;
#endif
else if (IS_UNPRINTABLE_ASCII(*p, *pr))
return n + 4;
else if (IS_UNPRINTABLE_CONTROL(*p, *pr))
return n + 2;
return n + 1;
}
int int
calcPosition(char *l, Lineprop *pr, int len, int pos, int bpos, int mode) calcPosition(char *l, Lineprop *pr, int len, int pos, int bpos, int mode)
{ {
@@ -494,7 +510,7 @@ calcPosition(char *l, Lineprop *pr, int len, int pos, int bpos, int mode)
} }
if (size < len + 1) { if (size < len + 1) {
size = (len + 1 > LINELEN) ? (len + 1) : LINELEN; size = (len + 1 > LINELEN) ? (len + 1) : LINELEN;
realColumn = New_Reuse(int, realColumn, size); realColumn = New_N(int, size);
} }
prevl = l; prevl = l;
j = bpos; j = bpos;
@@ -502,24 +518,31 @@ calcPosition(char *l, Lineprop *pr, int len, int pos, int bpos, int mode)
realColumn[i] = j; realColumn[i] = j;
if (i == len) if (i == len)
break; break;
if (l[i] == '\t' && pr[i] == PC_CTRL) j = nextColumn(j, &l[i], &pr[i]);
j = (j + Tabstop) / Tabstop * Tabstop;
#ifndef KANJI_SYMBOLS
else if (pr[i] & PC_RULE)
j++;
#endif
else if (IS_UNPRINTABLE_ASCII(l[i], pr[i]))
j = j + 4;
else if (IS_UNPRINTABLE_CONTROL(l[i], pr[i]))
j = j + 2;
else
j++;
} }
if (pos >= i) if (pos >= i)
return j; return j;
return realColumn[pos]; return realColumn[pos];
} }
int
columnLen(Line *line, int column)
{
int i, j;
for (i = 0, j = 0; i < line->len; i++) {
j = nextColumn(j, &line->lineBuf[i], &line->propBuf[i]);
if (j > column) {
#ifdef JP_CHARSET
if (CharType(line->propBuf[i]) == PC_KANJI2)
return i - 1;
#endif
return i;
}
}
return line->len;
}
char * char *
lastFileName(char *path) lastFileName(char *path)
{ {
+4 -18
View File
@@ -1,4 +1,4 @@
/* $Id: file.c,v 1.215 2003/01/30 16:32:00 ukai Exp $ */ /* $Id: file.c,v 1.216 2003/01/30 16:39:36 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include <sys/types.h> #include <sys/types.h>
#include "myctype.h" #include "myctype.h"
@@ -6128,23 +6128,9 @@ addnewline(Buffer *buf, char *line, Lineprop *prop,
bwidth = 0; bwidth = 0;
while (1) { while (1) {
l = buf->currentLine; l = buf->currentLine;
l->width = COLPOS(l, l->len);
l->bpos = bpos; l->bpos = bpos;
l->bwidth = bwidth; l->bwidth = bwidth;
if (l->width <= width) i = columnLen(l, width);
return;
i = columnPos(l, width);
#ifdef JP_CHARSET
if (CharType(p[i]) == PC_KANJI2)
i--;
#endif
if (i > 0 && COLPOS(l, i) > width) {
i--;
#ifdef JP_CHARSET
if (CharType(p[i]) == PC_KANJI2)
i--;
#endif
}
if (i == 0) { if (i == 0) {
i++; i++;
#ifdef JP_CHARSET #ifdef JP_CHARSET
@@ -6152,10 +6138,10 @@ addnewline(Buffer *buf, char *line, Lineprop *prop,
i++; i++;
#endif #endif
} }
if (i == l->len)
return;
l->len = i; l->len = i;
l->width = COLPOS(l, l->len); l->width = COLPOS(l, l->len);
if (pos <= i)
return;
bpos += l->len; bpos += l->len;
bwidth += l->width; bwidth += l->width;
s += i; s += i;
+2 -1
View File
@@ -1,4 +1,4 @@
/* $Id: proto.h,v 1.86 2003/01/29 17:38:15 ukai Exp $ */ /* $Id: proto.h,v 1.87 2003/01/30 16:39:40 ukai Exp $ */
/* /*
* This file was automatically generated by version 1.7 of cextract. * This file was automatically generated by version 1.7 of cextract.
* Manual editing not recommended. * Manual editing not recommended.
@@ -302,6 +302,7 @@ extern void cursorXY(Buffer *buf, int x, int y);
extern void restorePosition(Buffer *buf, Buffer *orig); extern void restorePosition(Buffer *buf, Buffer *orig);
extern int columnSkip(Buffer *buf, int offset); extern int columnSkip(Buffer *buf, int offset);
extern int columnPos(Line *line, int column); extern int columnPos(Line *line, int column);
extern int columnLen(Line *line, int column);
extern Line *lineSkip(Buffer *buf, Line *line, int offset, int last); extern Line *lineSkip(Buffer *buf, Line *line, int offset, int last);
extern Line *currentLineSkip(Buffer *buf, Line *line, int offset, int last); extern Line *currentLineSkip(Buffer *buf, Line *line, int offset, int last);
extern int gethtmlcmd(char **s); extern int gethtmlcmd(char **s);