commit 645e409794cbce0cbc1f2e44cb71d2d67d529bb8
parent 9db90be4bbe53cb0fcd6e778630eafdadd702dc6
Author: ukai <ukai>
Date: Thu, 30 Jan 2003 16:39:29 +0000
[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>
Diffstat:
4 files changed, 50 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,5 +1,15 @@
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>
+
* [w3m-dev 03717] print newline before exec shell command.
* main.c (execsh): print newline
diff --git a/etc.c b/etc.c
@@ -478,6 +478,22 @@ checkType(Str s, Lineprop **oprop
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
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) {
size = (len + 1 > LINELEN) ? (len + 1) : LINELEN;
- realColumn = New_Reuse(int, realColumn, size);
+ realColumn = New_N(int, size);
}
prevl = l;
j = bpos;
@@ -502,24 +518,31 @@ calcPosition(char *l, Lineprop *pr, int len, int pos, int bpos, int mode)
realColumn[i] = j;
if (i == len)
break;
- if (l[i] == '\t' && pr[i] == PC_CTRL)
- 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++;
+ j = nextColumn(j, &l[i], &pr[i]);
}
if (pos >= i)
return j;
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 *
lastFileName(char *path)
{
diff --git a/file.c b/file.c
@@ -6128,23 +6128,9 @@ addnewline(Buffer *buf, char *line, Lineprop *prop,
bwidth = 0;
while (1) {
l = buf->currentLine;
- l->width = COLPOS(l, l->len);
l->bpos = bpos;
l->bwidth = bwidth;
- if (l->width <= 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
- }
+ i = columnLen(l, width);
if (i == 0) {
i++;
#ifdef JP_CHARSET
@@ -6152,10 +6138,10 @@ addnewline(Buffer *buf, char *line, Lineprop *prop,
i++;
#endif
}
- if (i == l->len)
- return;
l->len = i;
l->width = COLPOS(l, l->len);
+ if (pos <= i)
+ return;
bpos += l->len;
bwidth += l->width;
s += i;
diff --git a/proto.h b/proto.h
@@ -302,6 +302,7 @@ extern void cursorXY(Buffer *buf, int x, int y);
extern void restorePosition(Buffer *buf, Buffer *orig);
extern int columnSkip(Buffer *buf, int offset);
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 *currentLineSkip(Buffer *buf, Line *line, int offset, int last);
extern int gethtmlcmd(char **s);