diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Emit generated runs in batches, not a write each
Diffstat (limited to 'source/ui-tree.c')
| -rw-r--r-- | source/ui-tree.c | 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 17 insertions, 6 deletions
diff --git a/source/ui-tree.c b/source/ui-tree.c index bc5986b..64be0b6 100644 --- a/source/ui-tree.c +++ b/source/ui-tree.c @@ -38,18 +38,31 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) html("<table summary='blob content' class='blob'>\n"); if (ctx.cfg.enable_tree_linenumbers) { + struct strbuf numbers = STRBUF_INIT; + html("<tr><td class='linenumbers'><pre>"); idx = 0; lineno = 0; + // Build the column in batches. A formatted write per line meant + // a syscall and a temporary buffer for every line of the file, + // which is most of what rendering a large blob cost, and the + // whole column at once would come to several times the blob. if (size) { - htmlf(numberfmt, ++lineno); + strbuf_addf(&numbers, numberfmt, ++lineno); while (idx < size - 1) { // skip absolute last newline - if (buf[idx] == '\n') - htmlf(numberfmt, ++lineno); + if (buf[idx] == '\n') { + strbuf_addf(&numbers, numberfmt, ++lineno); + if (numbers.len >= HTML_BATCH) { + html_raw(numbers.buf, numbers.len); + strbuf_reset(&numbers); + } + } idx++; } + html_raw(numbers.buf, numbers.len); } + strbuf_release(&numbers); html("</pre></td>\n"); } else { @@ -75,8 +88,6 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) html("</code></pre></td></tr></table>\n"); } -#define ROWLEN 32 - static void print_binary_buffer(char *buf, unsigned long size) { unsigned long ofs, idx; @@ -105,6 +116,7 @@ static void print_binary_buffer(char *buf, unsigned long size) html_txt(ascii); html("</td></tr>\n"); } + strbuf_release(&row); html("</table>\n"); } @@ -393,7 +405,6 @@ static void ls_tree(const struct object_id *oid, const char *path, struct walk_t ls_tail(); } - static int walk_tree(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, void *cbdata) { |
